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 and flow from this site, held on your device and searchable with no connection. Free to install, no ads.
Get it free on the App Store