Write a query to identify the top 10% of users based on watch time over the last 30 days.
Use the users and watch_sessions tables. Include users with no qualifying watch activity, and use user_id ascending as the deterministic tie-breaker.
user_id, display_name, total_watch_seconds, and watch_rank.watch_rank, then user_id.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| display_name | VARCHAR(100) | User display name |
| account_status | VARCHAR(20) | Current account status |
| Column | Type | Description |
|---|---|---|
| session_idPK | INT | Unique viewing session identifier |
| user_id | INT | User who watched the content |
| started_at | TIMESTAMP | Session start timestamp |
| watch_seconds | INT | Number of seconds watched |
| device_type | VARCHAR(30) | Device used for viewing |