AI engineering glossary · SQL databases

What is GROUP BY?

GROUP BY: A clause that collects rows sharing the same value in the listed columns into groups, so an aggregate function can be computed for each group. Every selected column must be either grouped or aggregated.

Level: beginnerTopic: SQL databases

GROUP BY: an example

SELECT city, COUNT(*) FROM customers GROUP BY city; returns one row per city with its customer count.

Related terms

More SQL databases terms

Where you learn it

GROUP BY is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.