GROUP BY
SafeGroup and aggregate
SELECT col, COUNT(*) FROM t GROUP BY col;
Aggregates per group with COUNT/SUM/AVG; filter aggregated results with HAVING, not WHERE.
Examples
SELECT status, COUNT(*) FROM orders GROUP BY status HAVING COUNT(*) > 100;Statuses above 100 rows
Syntax
SELECT col, AGG(x) FROM t GROUP BY col [HAVING cond];
Before you run it
Read only.
Related commands
- SELECTRead data
- SELECT ... JOINJoin tables
The same reference, with no signal at all
Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).
Get it free on the App Store