//Rollup Used
SELECT
CASE WHEN GROUPING(customername) = 1 THEN ‘All Customer’ ELSE customername END CustomerName,
CASE WHEN GROUPING(itemname) = 1 THEN ‘All Items’ ELSE itemname END ItemName,
SUM(Quantity*PricePerCase)
FROM orders
GROUP BY customername,itemname
WITH ROLLUP
SELECT
CASE WHEN GROUPING(customername) = 1 THEN ‘All Customer’ ELSE customername END CustomerName,
CASE WHEN GROUPING(itemname) = 1 THEN ‘All Items’ ELSE itemname END ItemName,
SUM(Quantity*PricePerCase)
FROM orders
GROUP BY customername,itemname
WITH ROLLUP
No comments:
Post a Comment