First page Back Continue Last page Image
Using a Hierarchical ROLLUP
SELECT vendor_state, vendor_city, COUNT(*) AS qty_vendors
FROM vendors
WHERE vendor_state IN ('IA', 'NJ')
GROUP BY vendor_state, vendor_city WITH ROLLUP
By Specifying multiple GROUP BY Criteria, you can generate multiple levels of ROLLUP output
Notice in this output we are getting rollups by state and a rollup for everything