
You are given signup data and user activity from an Asana-style product. Write a SQL query to return the first meaningful action each user took after signup. Treat an action as meaningful only when is_meaningful = true, and only consider events that happened at or after the user's signup_at timestamp. If a user has no meaningful post-signup action, they should still appear in the output with NULL action fields.
Return one row per user with the user id, email, signup timestamp, first meaningful event timestamp, action name, and surface name. If multiple qualifying events share the same timestamp for a user, break ties by the smaller event_id.
users| column | type | description |
|---|---|---|
| user_id | INT | Unique user identifier |
| VARCHAR(255) | User email | |
| signup_at | TIMESTAMP | Signup timestamp |
| workspace_id | INT | Workspace tied to signup |
event_types| column | type | description |
|---|---|---|
| event_type_id | INT | Unique event type identifier |
| action_name | VARCHAR(100) | Product action name |
| surface_name | VARCHAR(100) | Asana surface where the action happened |
| is_meaningful | BOOLEAN | Whether the event counts as meaningful activation |
user_events| column | type | description |
|---|---|---|
| event_id | INT | Unique event identifier |
| user_id | INT | User who triggered the event |
| event_type_id | INT | Event type |
| event_at | TIMESTAMP | Event timestamp |
| metadata | TEXT | Optional event metadata |
users| user_id | signup_at | |
|---|---|---|
| 101 | ava@acme.com | 2024-01-01 09:00:00 |
| 102 | ben@acme.com | 2024-01-01 09:30:00 |
| 103 | chloe@acme.com | 2024-01-02 10:00:00 |
user_events| event_id | user_id | event_type_id | event_at |
|---|---|---|---|
| 1001 | 101 | 1 | 2024-01-01 09:05:00 |
| 1002 | 101 | 3 | 2024-01-01 09:10:00 |
| 1005 | 102 | 4 | 2024-01-01 09:35:00 |
| user_id | signup_at | first_meaningful_event_at | action_name | surface_name | |
|---|---|---|---|---|---|
| 101 | ava@acme.com | 2024-01-01 09:00:00 | 2024-01-01 09:10:00 | create_project | web_app |
| 102 | ben@acme.com | 2024-01-01 09:30:00 | 2024-01-01 09:35:00 | invite_teammate | onboarding_flow |
| 103 | chloe@acme.com | 2024-01-02 10:00:00 | NULL | NULL | NULL |
| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| VARCHAR(255) | User email address | |
| signup_at | TIMESTAMP | Timestamp when the user signed up |
| workspace_id | INT | Workspace associated with the signup |
| Column | Type | Description |
|---|---|---|
| event_type_idPK | INT | Unique event type identifier |
| action_name | VARCHAR(100) | Name of the action taken |
| surface_name | VARCHAR(100) | Asana surface where the action occurred |
| is_meaningful | BOOLEAN | Whether the event counts as meaningful activation |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event identifier |
| user_id | INT | User who triggered the event |
| event_type_id | INT | Type of event triggered |
| event_at | TIMESTAMP | Timestamp of the event |
| metadata | TEXT | Optional event metadata |
{"users":[[101,"ava@acme.com","2024-01-01 09:00:00",10],[102,"ben@acme.com","2024-01-01 09:30:00",10],[103,"chloe@acme.com","2024-01-02 10:00:00",11],[104,"diego@acme.com","2024-01-02 11:00:00",11],[105,"emma@acme.com","2024-01-03 08:00:00",12],[106,"farah@acme.com","2024-01-03 08:15:00",null],[107,"gabe@acme.com","2024-01-04 14:00:00",13],[108,"hana@acme.com","2024-01-05 16:30:00",13],["1","owen@acme.com","2023-12-30 00:42:31","21"],["2","owen@acme.com","2024-01-01 06:33:10","null"],["3","yasmiOutput[["1","owen@acme.com","2023-12-30 00:42:31","null","null","null"],["2","owen@acme.com","2024-01-01 06:33:10","null","null","null"],["3","yasmin@acme.com","2024-01-02 21:07:23","null","null","null"],["4","owen@acme.com","2024-01-04 03:36:32","null","null","null"],["5","isaac@acme.com","2023-12-31 00:34:16","null","null","null"],["6","quentin@acme.com","2024-01-03 16:43:09","null","null","null"],["7","diego@acme.com","2024-01-04 12:53:55","null","null","null"],["8","nora@acme.com","2023-12-31 08:4