Your question is SQL Top User Segments. 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 a SQL query to identify the top three user segments by engagement over the last quarter.
Use the provided Wise. Energy user, segment, and engagement data. Define engagement as the number of engagement events during the previous calendar quarter.
segment_name, engagement_count, and active_users| Column | Type | Description |
|---|---|---|
| segment_idPK | INT | Unique user segment identifier |
| segment_name | VARCHAR(100) | Display name of the user segment |
| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique Wise. Energy user identifier |
| segment_id | INT | Assigned user segment |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique engagement event identifier |
| user_id | INT | User associated with the engagement event |
| event_type | VARCHAR(50) | Type of engagement activity |
| event_timestamp | TIMESTAMP | Timestamp when the engagement occurred |