
8.2
GROUP BY Clause Extensions 221
Chapter 8
GROUP BY l.city
UNION ALL
SELECT NULL AS City, NULL AS Industry, NULL AS Category
,SUM(s.transaction_amount) AS Amount
FROM sale s, location l, industry i, product p
WHERE l.city IN('New York','Los Angeles')
AND s.time_id=8
AND s.location_id = l.location_id
AND s.industry_id = i.industry_id
AND s.product_id = p.product_id
ORDER BY 1 DESC NULLS LAST, 2 DESC NULLS LAST
, 3 DESC NULLS LAST;
The result of this horribly complex query is shown in Figure 8.3, verify-
ing the identical result as Figure 8.2 when using the ROLLUP clause.
The entire query is not displayed in Figure 8.3 because there is simply
too much of ...