SQL Query – Order of execution

Order of execution

When you execute a SQL Query, it will be executed in the following sequence.

FROM

ON

JOIN

WHERE

GROUP BY

HAVING

SELECT

DISTINCT

ORDER BY

TOP

Latest Comments
  1. Andy

    I have seen in some community posts that -“SQL has no order of execution. Is a declarative language. The optimizer is free to choose any order it feels appropriate to produce the best execution time. Given any SQL query, is basically impossible to anybody to pretend it knows the execution order.” I would like to hear your reply on this post soon :).

    • Chandrasekhar Raparthi

      Dear Andy,

      SQL has pre defined order of execution which Engine follows. As per my knowledge, Engine does not change the order of execution according to the query.

      If possible, could you please share the links of the community posts which you have read.

      Once again Thank you very much for showing interest on SQLVersity.

      ALL THE BEST :)

Leave a Reply

Your email address will not be published. Required fields are marked *