Database · Medium
Write a monthly revenue report grouped by product category.
DatabaseSQL QueriesSenior
Answer preview
Bucket the dates with date_trunc('month', …) and aggregate once — COUNT, SUM, and AVG all read the same group, so this is a single pass with no self-joins.…