Home > DB Concepts > SQL Logical Query Processing Order

SQL Logical Query Processing Order

October 28, 2010 Leave a comment Go to comments

–>Logical Query-processing step numbers:

(5) SELECT (5-2) DISTINCT (7) TOP(<top_specification>) (5-1) <select_list>
(1) FROM (1-J) <left_table> <join_type> JOIN <right_table> ON <on_predicate>
| (1-A) <left_table> <apply_type> APPLY <right_input_table> AS <alias>
| (1-P) <left_table> PIVOT(<pivot_specification>) AS <alias>
| (1-U) <left_table> UNPIVOT(<unpivot_specification>) AS <alias>
(2) WHERE <where_predicate>
(3) GROUP BY <group_by_specification>
(4) HAVING <having_predicate>
(6) ORDER BY <order_by_list>
(7) OFFSET <offset_specs> ROWS FETCH NEXT <fetch_specs> ROWS ONLY;

–> Logical step sequence of a Query:
1. FROM / JOIN/ APPLY/ PIVOT/ UNPIVOT
2. WHERE
3. GROUP BY
4. HAVING
5. SELECT list/ DISTINCT
6. ORDER BY
7. TOP/ OFFSET-FETCH

–> Flow diagram representing logical query-processing:

SQL Logical Query Processing Order

SQL Logical Query Processing Order

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.