Write a SQL query to find the top 3 customers with the highest data usage per month over the last year at Vodafone. Use the provided Vodafone customer, account, and usage data. Include months represented by qualifying usage records during the trailing 12-month period.
Output
- One row per customer-month among the top three customers for that month.
- Columns:
usage_month, customer_id, customer_name, total_data_usage_mb, and monthly_rank.
- Return at most three rows per month, ordered by
usage_month, then monthly_rank, then customer_id. Break equal usage totals by the lower customer_id.
Output details
- Treat
DATE '2026-01-15' as today's date.
- Include usage records on both boundary dates, from
2025-01-15 through 2026-01-15 inclusive.
- Represent
usage_month as the first day of each calendar month.
- Retain zero-valued usage totals and rank them normally.
- Sort NULL usage totals after non-NULL totals.