Practical T-SQL
Comment on page

Lesson 3. Basic Syntax

The elements of a SQL statement are called clauses. Clauses have to be written in a certain order. You cannot deviate from this order. If you attempt to perform an operation out of order, your SQL statement will fail to execute.


SQL Statement Clause Order
USE AdventureWorks2016
SELECT --the columns you want to look at
FROM --from the tables the columns live in
WHERE --where your specified filter conditions are met
GROUP BY --the columns you wish to summarize data on
HAVING --the conditions you specify
ORDER BY --sorted by the conditions you specify