From the course: Oracle Database 19c: Basic SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

HAVING clause

HAVING clause

From the course: Oracle Database 19c: Basic SQL

Start my 1-month free trial

HAVING clause

- [Instructor] If you have a HAVING clause in your SELECT statement that means you must have a GROUP BY as well. I'll show you where HAVING is allowed, how to use it, and some other options you can use with HAVING. The HAVING clause is a filter, but for the GROUP BY clause. The GROUP BY clause, discussed in another lesson, aggregates rows across one or more other columns showing the results of multi-row functions. If you want precise results, or you have too many results, you can use HAVING to narrow those down. Here's the syntax of the SELECT statement. The HAVING clause must come after the GROUP BY clause, but before the final ORDER BY clause. The HAVING clause is optional, but you can only use it if you have a GROUP BY clause with a non-aggregated column or expression in the SELECT statement. Here's an example of using the HAVING clause as a filter after the totals have been aggregated. Without HAVING, the query returns 12 aggregated rows. By showing only the departments with more…

Contents