What is the order in which SQL clauses are executed?
Model answer
Written order is SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT. Logical execution order is FROM and JOINs, WHERE, GROUP BY, HAVING, SELECT, DISTINCT, ORDER BY, then LIMIT. This explains why you cannot use a SELECT alias in WHERE in most databases.
Learn this topic
What Is SQL and What Is a Database? in the course SQL for Beginners: Learn Databases Step by Step.
Sign in to add your own answer.