Write a query to find the top three spending categories for each user over the last 90 days, ranking them dynamically at Truebill.
Assume the reporting date is 2025-04-01. Include positive, non-null transactions from the 90-day period ending immediately before that date.
Output
- One row per user and qualifying category, limited to the top three categories for each user.
- Columns:
user_id, user_name, category_name, total_spent, and category_rank.
- Rank by total spending descending, with category name ascending as the tie-breaker.
- Order by
user_id, then category_rank.