HAVING

A conditional statement similar to WHERE but used with aggregate functions (COUNT(), MIN(), MAX(), SUM(), AVG()).

Code Example

To return a result set of the number (count) of students from each country if the total number is less than 25:

SELECT COUNT(student_name),
birth_country
FROM students
GROUP BY birth_country
HAVING COUNT(student_name) < 25;

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn SQL on Codecademy

Contributors