Your question is SQL First Message Per User. Start with the requirements and the one table 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.
Tinder's messaging analytics team wants to identify the first message sent by each user. This helps measure how quickly new matches begin conversations.
Write a PostgreSQL query against user_messages to return the first message for every user with at least one non-null timestamp.
user_id.timestamp for each user.message_id as the deterministic tie-breaker.user_id, message_id, and timestamp, ordered by user_id.| Column | Type | Description |
|---|---|---|
| user_id | INTEGER | Tinder user who sent the message |
| message_idPK | VARCHAR(12) | Unique identifier for the message |
| timestamp | TIMESTAMPTZ | Timestamp when the message was sent |