Query
-- Customer using the most roaming minutes in 2000
SELECT Cust_Name,
Calendar_Year,
SUM(Total_Roaming_minutes) AS TOTAL_ROAMING
FROM Billing_Fact Bill_Fact,
Date_Dimension Date_Dim,
Customer_Details_Dimension Cust_Dim
WHERE Bill_Fact.Cust_Key = Cust_Dim.Cust_Key
AND Bill_Fact.Date_Key = Date_Dim.Date_Key
AND Date_Dim.Calendar_Year = 2000
AND Bill_Fact.Roaming_Flag = 1
GROUP BY Cust_Name,Calendar_Year
ORDER BY Cust_Name,
TOTAL_ROAMING DESC;
Example
Cust_Name | Calendar_Year | Total_Roaming
-------------+---------------+---------------
(null) | 2000 | 361
Abigail | 2000 | 323
Andrew | 2000 | 216
Anthony | 2000 | 384
AshleyJack | 2000 | 378
Ava | 2000 | 243
(29 rows)