SQLQuokka
Start practicing
QuestionsLearnSandboxFeaturesRoadmapFAQ

Current and Previous Subscription Plan

Unsolved

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.

SQL Query Editor (Ctrl+Enter to run)
0 characters · Valid
Canonical Solution Official

Official Solution is Hidden

Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.

Community Q&A & Discussion

Ask questions, share alternate queries, and explore solutions

0 comments
Asked By:
🏢 Dropbox🏢 Netflix🏢 Spotify

Submission History

Your recent query executions and answer checks

Execution Pipeline:
FROM plan_changes
Full source dataset
11 rows total
Ready. Type a query to see live execution.
Clause: Auto-Sync · AlaSQL Engine