85
General form of Grouping and Aggregation
•SELECT    S
•FROM       R1,…,Rn
•WHERE    C1
•GROUP BY a1,…,ak
•HAVING     C2
•
•Evaluation steps:
1.Compute the FROM-WHERE part, obtain a table with all attributes in R1,…,Rn
2.Group by the attributes a1,…,ak 
3.Compute the aggregates in C2 and keep only groups satisfying C2
4.Compute aggregates in S and return the result