Write a query to find the top 3 users by revenue in each distinct product category.
Calculate revenue as the sum of order totals for each user and product category. Exclude orders without matching users or products, and exclude products without a category. Break revenue ties by ascending user_id.
Output
- One row per qualifying user and product category, with columns
category, user_id, user_name, total_revenue, and category_rank.
- Include no more than three users per category.
- Order by
category ascending, category_rank ascending, then user_id ascending.