Aggregate values per group.
Section: Aggregation and Grouping
Group by a column
sql
sql
SELECT status, COUNT(*) AS total
FROM orders
GROUP BY status;Explanation
All non-aggregated selected columns must appear in GROUP BY.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Aggregation and Grouping