Query
-- Total service tax and surcharge paid to government in 2000
SELECT Calendar_Year,
Calendar_Year_Month,
SUM(Service_Tax) AS SERVICE_TAX,
SUM(SURCHARGE) AS SURCHARGE
FROM Billing_Fact Bill_Fact,
Date_Dimension Date_Dim
WHERE Bill_Fact.Date_Key = Date_Dim.Date_Key
AND Date_Dim.Calendar_Year = 2000
GROUP BY Calendar_Year,Calendar_Year_Month
ORDER BY Calendar_Year,
Calendar_Year_Month DESC;
Example
Calendar_Year | Calendar_Year_Month | Service_Tax | Surcharge
---------------+---------------------+-------------+-----------
2000 | 12 | 67.405 | 6.7405
2000 | 11 | 45.615 | 4.5615
2000 | 10 | 49.315 | 4.9315
2000 | 9 | 63.495 | 6.3495
2000 | 8 | 62.53 | 6.253
(12 rows)