Dan Drust

Software Engineer
based in West Michigan

Database Daily: Group By Aggregation

2 June 2023

After an embarassing foray into math, I implemented the ability to do something like SELECT COUNT(id) GROUP BY age. This added awareness of when a grouped set starts/ends while the Aggregate node is reading it’s input stream.

No ah-ha moments yet around things like COUNT(DISTINCT age). Though at a few points I thought about how output schema (and aggregates inside of it) might be a separate concern from the grouping/aggregating dimensions. I’d like to pull that thread next time so that I could implement something like SELECT array_agg(name), count(id), age FROM users group by age – where the output tuples follow the array_agg(name), count(id), age schema.


Written by Dan Drust on 2 June 2023

Continue Reading: Database Daily: Aggregation

Browse more posts