GROUP BY

Groups a result set based on an aggregate function (COUNT(), MIN(), MAX(), SUM(), AVG()). It lists the number in each group.

Code Example

To return a result set of the number (count) of students from each country:

SELECT COUNT(student_name),
birth_country
FROM students
GROUP BY birth_country;
Edit this page on GitHub

Contributors

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

Learn SQL on Codecademy

Edit this page on GitHub

Contributors