Your question is Top Users SQL Query. Start with the requirements and the three tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write an SQL query to find the top 3 users based on their interactions on a given day.
Use 2025-02-14 as the given day. Count only countable interaction types and interactions that are not deleted. Rows with a NULL interaction timestamp are ignored.
user_id, username, interaction_count, and rank.user_id ascending.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique user identifier |
| username | VARCHAR(100) | User display name |
| Column | Type | Description |
|---|---|---|
| interaction_type_idPK | INTEGER | Unique interaction type identifier |
| interaction_type_name | VARCHAR(80) | Name of the interaction type |
| is_countable | BOOLEAN | Whether this interaction type contributes to user counts |
| Column | Type | Description |
|---|---|---|
| interaction_idPK | INTEGER | Unique interaction identifier |
| user_id | INTEGER | User associated with the interaction |
| interaction_type_id | INTEGER | Type associated with the interaction |
| occurred_at | TIMESTAMP | Timestamp when the interaction occurred |
| is_deleted | BOOLEAN | Whether the interaction has been deleted |