Task
You are given user signup data and Chime cash movement events. Write a SQL query to return each signed-up user and the date of their first completed deposit that occurred on or after their signup timestamp. Include users who never made a qualifying deposit, showing NULL for the deposit date. Treat only transactions with transaction_type = 'deposit' and status = 'completed' as valid deposits.
Schema
users
| column | type | description |
|---|
| user_id | INT | Unique user identifier |
| email | VARCHAR(255) | User email |
| signup_at | TIMESTAMP | Signup timestamp |
| acquisition_channel | VARCHAR(50) | Signup source |
chime_transactions
| column | type | description |
|---|
| transaction_id | INT | Unique transaction identifier |
| user_id | INT | User who initiated the transaction |
| transaction_type | VARCHAR(50) | Type such as deposit, withdrawal, transfer |
| status | VARCHAR(50) | Transaction status |
| amount | NUMERIC(10,2) | Transaction amount |
| transaction_at | TIMESTAMP | Transaction timestamp |
| source_surface | VARCHAR(50) | Product surface where the event originated |
Sample data
users
chime_transactions
| transaction_id | user_id | transaction_type | status | transaction_at |
|---|
| 2001 | 101 | deposit | completed | 2024-01-04 18:00:00 |
| 2002 | 101 | deposit | completed | 2024-01-05 10:00:00 |
| 2005 | 102 | deposit | pending | 2024-01-04 09:00:00 |
Expected output