Dropbox stores every subscription plan change as a row in `plan_changes`. The most recent change per user (by `changed_at`) is that user's current plan. Write an SQL query that returns, for every user, `user_id`, `current_plan` and `previous_plan` (the plan immediately before the current one, or NULL if the user has only ever had one plan). Order the results by `user_id` ascending.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.