From the course: Oracle Database 12c: Basic SQL
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Using HAVING - Oracle Database Tutorial
From the course: Oracle Database 12c: Basic SQL
Using HAVING
- [Narrator] The having clause in a sequel query allows us to filter records based on summarized group by results. Having, when use as part of the sequel query, applies to the summarized group records, where as using where applies to individual records. Let's see the having clause in action. We'll start by typing a query that will show us the average salary per department from our employees table. I'll type select average salary comma department id from employees group by department id. Executing this query will provide us with the average salary per department. To make things nicer to view, let's nest the average function inside a round function. There we go. Let's say that you only want to see departments where the average salary is greater than $9,000. For example, we want to exclude departments such as 30 or 50, where the average salary is lower than $9,000. I cannot do this using a where clause because where applies…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.