Grouping and Aggregation
Usually, we want aggregations on certain parts of the relation.
Find how much we sold of every product
SELECT product, Sum(price)
WHERE Product.name = Purchase.product
1. Compute the relation (I.e., the FROM and WHERE).
2. Group by the attributes in the GROUP BY
3. Select one tuple for every group (and apply aggregation)
SELECT can have (1) grouped attributes or (2) aggregates.