Ordering
Eliminating duplicate results
Aggregation
Grouping
HAVING: filtering and ordering groups
21. Filter groups continued
Let's practice

Instruction

You're getting really good! Now, let's do one more exercise on filtering groups. Are you ready?

Exercise

Find such departments where the average salary in 2012 was higher than 3000. Show the department name with the average salary.

Stuck? Here's a hint!

Type:

SELECT
department,
avg(salary)
FROM employees
WHERE year = 2012
GROUP BY department HAVING avg(salary) > 3000;