SQL Query executes in a particular order. The Query execution is a shadow to any developer. In this post, I have explained the execution flow of the SQL query.
Order of SQL statements
- FROM clause
- WHERE clause
- GROUP BY clause
- HAVING clause
- SELECT clause
- ORDER BY clause
SELECT id, language, author creator FROM proglang_tbl ORDER BY creator;In the above SQL, first FROM executes, next SELECT and the last is ORDER BY. See the below video for all clauses.
Video on SQL Order of Execution
Why ORDER BY is LastIn any database, the ORDER BY executes at the end. That means Sorting takes place only at the end.