Aggregate records
Summarize rows with COUNT, SUM, AVG and GROUP BY.
Example
Section titled “Example”CREATE TABLE docs_metrics (id BIGINT PRIMARY KEY, team TEXT, amount BIGINT);INSERT INTO docs_metrics VALUES (1, 'support', 10), (2, 'support', 30), (3, 'platform', 20);SELECT team, COUNT(*) AS records, SUM(amount) AS total, AVG(amount) AS meanFROM docs_metrics GROUP BY team ORDER BY team;Behavior
Section titled “Behavior”Platform has one record totaling 20. Support has two totaling 40. WHERE filters input records; HAVING filters groups. COUNT(*) counts rows, while COUNT(column) ignores null values.
Related
Section titled “Related”This site uses Google Analytics cookies to count visits. Privacy · License