O'Reilly logo

Simply SQL by Rudy Limeback

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required