Glossary · Database

Aggregation

A SQL operation that computes a single result from a set of values, such as SUM, COUNT, AVG, MIN, or MAX.

Aggregation in SQL refers to operations that compute a single summary value from a set of input values. The standard aggregate functions are COUNT (number of rows), SUM (total of values), AVG (average), MIN (smallest value), and MAX (largest value). Aggregations are typically combined with GROUP BY to compute summaries per group (e.g., total revenue per department) and HAVING to filter groups based on aggregate values. Advanced aggregations include PERCENTILE_CONT, STRING_AGG, ARRAY_AGG, and user-defined aggregate functions. Window functions (OVER clause) provide aggregations across a "window" of rows related to the current row without collapsing the result set–enabling running totals, moving averages, and rankings.

In practice

How AI for Database applies it

AI for Database automatically applies the right aggregations when you ask summary questions like "What is the total revenue by region?"
Database · aifordatabase glossaryRead-only ✓

Fig — every answer ships with the tables, rows and SQL behind it.

See it on your own database

Connect read-only in minutes. Free models included.

Start free