SQL Server Interview: What is the logical order of SQL Query (SELECT Statement)

I have already shared hundreds of SQL Server Interview Questions.
Here, I would like to share one more common and important SQL Interview question for SQL Beginner.

Whenever I am taking the SQL Beginner’s Interview, I always ask one question “What is the logical order of SQL Query or SELECT Statement”.

It looks like a very basic question, but It is very important to know about the sequence of query execution because It plays main role in query optimization.

You should know that JOINS are executing the first or WHERE clause is executing the first. Both are filtering the data, but most of the time I have found a wrong answer.

Below is a correct logical order of SQL Query or SELECT Statement:

  • FROM
  • ON
  • JOIN
  • WHERE
  • GROUP BY
  • WITH CUBE or WITH ROLLUP
  • HAVING
  • SELECT
  • DISTINCT
  • ORDER BY
  • TOP


Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from dbrnd.com