January 2018
Intermediate to advanced
446 pages
12h 57m
English
You can filter results of the GROUP BY clause by adding the HAVING clause.
For example, find the employees with an average salary of more than 140,000:
mysql> SELECT emp_no, AVG(salary) AS avg FROM salaries GROUP BY emp_no HAVING avg > 140000 ORDER BY avg DESC;+--------+-------------+| emp_no | avg |+--------+-------------+| 109334 | 141835.3333 || 205000 | 141064.6364 |+--------+-------------+2 rows in set (0.80 sec)
Read now
Unlock full access