Limiting Selected Records by Using a Group Function

The last SELECT statement clause to be discussed is the HAVING clause. This clause is similar to the WHERE clause in that it determines whether the record is eligible for selection. The clause contains arguments used to evaluate records. Multiple conditions can be placed in the HAVING clause. The AND and OR keywords can also be used within the clause to develop complex logic.

The difference between the HAVING clause and the WHERE clause is that one of the arguments in a HAVING clause condition must be a group function. The HAVING clause is used only when a grouped value is computed by the SELECT statement. This requires a group function to exist in the SELECT clause. Listing 5.15 illustrates ...

Get Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts 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.