Course Process
HAVING Clause MYSQL
The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions.
Syntax:
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);
Query:
SELECT count(emp_no),year(hire_date) FROM `employees`
group by year(hire_date)
having count(emp_no) >5000
Output:
Tester Usage Tips:
- Validate group of records from a query result with a condition or UI records
- Validate invalid data in not included in summary reports