Database Reference
In-Depth Information
Table 13.2
SELECT
Clauses and Their Sequence
Clause
Description
Required
SELECT
Columns or expressions
Yes
to be returned
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
LIMIT
Number of rows to retrieve
No
In Chapter 12, “Summarizing Data,” you learned how to use the SQL aggre-
gate functions to perform summary calculations on your data. In this chapter,
you learned how to use the
GROUP BY
clause to perform these calculations
on groups of data, returning results for each group. You saw how to use the
HAVING
clause to filter specific groups. You also learned the difference between
ORDER BY
and
GROUP BY
and between
WHERE
and
HAVING
.