GROUP BY command groups a result-set of rows, usually based on an aggregate function.
SELECT column(s) FROM table GROUP BY column(s)
The aggregate function is usually applied on the same line as the SELECT command.
The following example returns a result set of the number (count) of students from each country:
SELECT COUNT(student_name),birth_countryFROM studentsGROUP BY birth_country;
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
Learn SQL on Codecademy
Analyze Data with SQLLearn to analyze data with SQL and prepare for technical interviews.
Includes 8 Courses
Design Databases With PostgreSQLLearn how to create and optimize a database from scratch using PostgreSQL
Includes 5 Courses