GROUP BY

noun

say it: “GROOP BY” /ɡruːp baɪ/

The part of a query that puts rows with the same values together, so aggregate functions give one result per group.

What is GROUP BY in a relational database?

GROUP BY — A clause collecting rows with equal grouping values so each group produces one result row.

SELECT customer_id, COUNT(*) AS order_count
FROM purchase_order
GROUP BY customer_id;

In a sentence

  • “GROUP BY Country gives one row per country with its customer count.”

Level: Apprentice · More SQL terms at this level

Updated