What is aggregation in a database query?
Aggregation is summarising many rows into a single value using functions like SUM, COUNT, AVG, MIN and MAX, usually grouped by a category. It turns raw records into meaningful metrics, for example total revenue per region or average order value per month.
Aggregation is how detail becomes insight. Instead of listing every order, you aggregate to get totals, averages and counts, typically with a GROUP BY that splits the calculation across categories.
Common aggregate functions:
- SUM totals (revenue, quantity).
- COUNT how many rows or distinct values.
- AVG averages (order value, response time).
- MIN / MAX extremes (earliest date, highest price).
Grouping controls the granularity: total sales overall, by month, by product, or by month and product together. Add filters (WHERE) and post-aggregation filters (HAVING) and you can answer most reporting questions.
Getting the grouping and filters exactly right is fiddly, and mistakes are easy to miss. iDBQuery writes the aggregation for you: ask 'total revenue by region last quarter' and it selects the right measure, groups by the right dimension, applies the date filter, and runs the SQL against your live data. It then cites the number back to the rows it aggregated, so you can confirm the total is built from exactly the records you expected, no silent double-counting.
Updated 2026-06-22