Your question is Trade Within 24 Hours. Start with the requirements and the two 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.
Vanguard Brokerage wants to measure how often users place a trade shortly after accessing their account. Write a PostgreSQL query to calculate the percentage of distinct users who completed at least one trade within 24 hours of any login.
Treat the 24-hour boundary as inclusive. A user should be counted only once, even if they have multiple qualifying logins or trades. Users with logins but no qualifying trade must remain in the denominator.
| Column | Type | Description |
|---|---|---|
| login_idPK | INTEGER | Unique login event identifier |
| user_id | INTEGER | Vanguard user identifier |
| login_at | TIMESTAMP | Timestamp when the user logged in |
| Column | Type | Description |
|---|---|---|
| trade_idPK | INTEGER | Unique trade identifier |
| user_id | INTEGER | User who placed the trade |
| traded_at | TIMESTAMP | Trade execution timestamp |