Chapter 11. SELECT Statement: The HAVING Clause

11.1 Introduction

The purpose of the HAVING clause of a select block is comparable to that of the WHERE clause. The difference is that the WHERE clause is used to select rows after the FROM clause has been processed, whereas the HAVING clause is used to select rows after a GROUP BY clause has been executed. A HAVING clause can be used without a GROUP BY clause.

image Definition

<having clause> ::=   HAVING <condition>

In the previous chapter, you saw that the GROUP BY clause groups the rows of the result from the FROM clause. The HAVING clause enables you to select groups (with rows) based upon their ...

Get SQL for MySQL Developers: A Comprehensive Tutorial and Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.