Chapter 6
The HAVING
Clause
In Chapter 5, we learned that the GROUP BY
clause produces group rows by aggregating rows of the tabular structure extracted from the database by the FROM
clause and then filtered by the WHERE
clause. Each distinct value or combination of values in the GROUP BY
column(s) forms a separate group row.
In this chapter, we’ll look at the HAVING
clause. This follows the GROUP BY
clause both in syntax (its position in the SELECT
statement) and in the sequence of execution. Its purpose is simple once you understand GROUP BY
and group rows. HAVING
is basically the same as WHERE
, with the difference that HAVING
works on group rows.
HAVING
Filters Group Rows
The purpose of the HAVING
clause is to act as a filter ...
Get Simply SQL 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.