SELECT Clause Ordering
This is probably a good time to review the order in which SELECT statement clauses are to be specified. Table 10.2 lists all the clauses we have learned thus far, in the order they must be used.
Clause | Description | Required |
---|---|---|
SELECT | Columns or expressions to be returned | Yes |
FROM | Table to retrieve data from | Only if selecting data from a table |
WHERE | Row-level filtering | No |
GROUP BY | Group specification | Only if calculating aggregates by group |
HAVING | Group-level filtering | No |
ORDER BY | Output sort order | No |
Get Sams Teach Yourself SQL in 10 Minutes, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.