Queries With GROUP BY and HAVING
The target-list contains (i) attribute names (ii) terms with aggregate operations (e.g., MIN (S.age)).
- The attribute list (i) must be a subset of grouping-list. Intuitively, each answer tuple corresponds to a group, and these attributes must have a single value per group. (A group is a set of tuples that have the same value for all attributes in grouping-list.)
SELECT [DISTINCT] target-list
HAVING group-qualification