Query
-- Best rate plan in use
SELECT Calendar_Year,
Calendar_Year_Month,
Plan_Name,
SUM(Number_Of_Calls) AS Calls,
SUM(Total_Minutes) AS Total_Minutes
FROM Billing_Fact Bill_Fact,
Date_Dimension Date_Dim,
Rate_Plan_Dimension Rate_Dim
WHERE Bill_Fact.Date_Key = Date_Dim.Date_Key
AND Bill_Fact.Plan_Key = Rate_Dim.Plan_Key
GROUP BY Calendar_Year,Calendar_Year_Month,Plan_Name
HAVING SUM(Number_Of_Calls) >= 10
ORDER BY Calls;
Example
Calendar_Year | Calendar_Year_Month | Plan_Name | Calls | Total_Minutes
---------------+---------------------+-------------------+-------+---------------
2000 | 12 | Freedom_40 | 10 | 18
2000 | 9 | Youth_45 | 10 | 48
2000 | 2 | Freedom_30 | 10 | 49
2000 | 6 | Flexi_40 | 10 | 35
2000 | 1 | Flexi_30 | 10 | 36
2000 | 9 | Youth_30 | 10 | 81
2000 | 6 | Youth_25 | 10 | 55
2000 | 10 | Executive_40 | 10 | 42
(319 rows)