Skip to content
ParticleDB
Release candidateParticleDB 1.1.19-rc.17 is not yet GA or ready for production data.Release status →

Aggregate records

Summarize rows with COUNT, SUM, AVG and GROUP BY.

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 mean
FROM docs_metrics GROUP BY team ORDER BY team;

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.

SQL reference · Application guide · Troubleshooting