Write a query using window functions and joins to identify the top three customer contact categories by order volume over a rolling 30-day period.
Use the provided orders, customer_contacts, and contact_categories tables. Count distinct orders with non-null contact dates, using an inclusive 30-day window consisting of the reporting date and prior 29 calendar days. Return exactly three categories when at least three qualify, with alphabetical category order breaking ties.
Output
- One row per qualifying category and reporting date, with
report_date, category_name, rolling_30_day_order_volume, and category_rank.
- Include only the top three categories for each reporting date, ordered by
report_date, category_rank, and category_name.