clause

GROUP BY

Combines input rows into groups for summary calculations. Example target: PostgreSQL 17 and SQLite (local fixture tested).

Formal Syntax & Structure

sql syntaxsql
GROUP BY expression [, ...]

Working Example

Example Snippetsql
SELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id ORDER BY customer_id;
SQL Reference