Definition
Grouping and Aggregation (Relational Algebra)
The grouping and aggregation operation, denoted by , is an operator that first partitions tuples of a relation into groups and then computes a single or multiple summary value for each group using an aggregate function.
This process involves two main steps:
- Grouping: Tuples that have the same values for all attributes in a specified grouping list are placed into the same group.
- Aggregation: An aggregate function (like
SUM
,COUNT
,AVG
,MIN
,MAX
) is applied to an attribute of the tuples within each group, producing a single value per group.where:
- is the list of attributes to group by
- is the aggregate function to be applied to each group. This also defines the new attribute for the aggregate value in the result schema (e.g., )
- is the input relation
The resulting relation consists of the grouping attributes in and the new attribute(s) generated by the aggregate function(s) in .