Write a SQL query using window functions to identify the top three most-watched content categories for each Roku user over the last 30 days.
Use the provided Roku user, content category, and viewing event tables. Treat total watch seconds as the measure of category viewership.
Output
- One row per qualifying user and category, with
user_id, username, category_name, total_watch_seconds, and category_rank
- Include only the top three categories per user, breaking ties alphabetically by category name
- Order by
user_id, then category_rank