Subscription Start Order
List every subscription record from earliest to latest, including its user and product.
- Date analysis
- Sorting
Challenge brief
Understand the request
Finance Operations is auditing subscription onboarding timelines and needs all subscriptions listed in the order they were started.
Show user_id and start_date from subscriptions, ordered by start_date ascending.
Return
- subscription_id
- user_id
- product_id
- start_date
Constraints
- Return every subscription record, including repeated subscriptions by the same user
- Order by start date and subscription ID
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
subscriptions
subscription_idINTEGERuser_idINTEGERproduct_idINTEGERstart_dateDATEend_dateDATEpriceINTEGER
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
All data is in subscriptions. No JOIN or GROUP BY needed. Just SELECT user_id and start_date, then ORDER BY start_date.
Hint 2
SELECT user_id, start_date FROM subscriptions ORDER BY start_date.
Hint 3
Build question 17 from the required result grain: choose the driving table, add only the joins and filters needed for that grain, then apply aggregation and deterministic ordering.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT subscription_id, user_id, product_id, start_date FROM subscriptions ORDER BY start_date, subscription_id;Why this works
Return subscription-grain identifiers so repeat subscriptions by one user remain distinguishable, then sort by start date and subscription ID for stability.
Success check
12 subscriptions — earliest is user 1 (Jan 1), latest is user 12 (Mar 22)
Expected result
Use this output to verify values, aliases, ordering, and row count.
| subscription_id | user_id | product_id | start_date |
|---|---|---|---|
| 1 | 1 | 1 | 2024-01-01 |
| 2 | 2 | 1 | 2024-01-10 |
| 13 | 1 | 2 | 2024-01-20 |
| 3 | 3 | 2 | 2024-02-05 |
| 4 | 4 | 3 | 2024-02-15 |
| 5 | 5 | 2 | 2024-03-05 |
| 6 | 6 | 1 | 2024-03-06 |
| 7 | 7 | 3 | 2024-03-10 |
| 8 | 8 | 2 | 2024-03-12 |
| 9 | 9 | 1 | 2024-03-15 |
Previewing 10 of 13 expected rows. Run the query in the editor to inspect the full result.
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Apple
Independent Apple-style product, retail, services, support, workforce, and device-usage SQL practice.
Google
Independent Google-style search, advertising, user-engagement, and video-product SQL practice.
Amazon
Independent Amazon-style e-commerce, warehouse, inventory, and customer analytics SQL practice.
Return to the complete interview preparation experience.