Netflix-style Company ChallengeEasyVerified answerSQLite live

User Subscription Details

Return user_id, country, plan, and monthly_fee for every user, ordered by user_id.

  • Joins
  • Sorting

Challenge brief

Understand the request

Customer Success Customer success needs a unified view of each user's country and plan to prepare for a retention outreach campaign.

Return user_id, country, plan, monthly_fee in the declared deterministic order.

Return

  • user_id
  • country
  • plan
  • monthly_fee

Constraints

  • Return every registered user, including users without a subscription
  • Use NULL plan and fee when no subscription exists
  • Order by user ID

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

users

  • user_idINTEGER
  • countryVARCHAR(50)

subscriptions

  • user_idINTEGER
  • planVARCHAR(20)
  • monthly_feeINTEGER

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

The user directory is the complete population; plan details are optional.

Hint 2

Preserve users while matching subscriptions on user ID.

Hint 3

Project both sources and order by the preserved identifier.

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT u.user_id, u.country, s.plan, s.monthly_fee FROM users u LEFT JOIN subscriptions s ON u.user_id = s.user_id ORDER BY u.user_id

Why this works

The user directory is the preserved population. An optional subscription match keeps newly registered users visible even when no plan record exists.

Success check

Every registered user appears once; unsubscribed users retain NULL plan details

Expected result

Use this output to verify values, aliases, ordering, and row count.

user_idcountryplanmonthly_fee
1USPremium20
2INBasic8
3UKStandard15
4CAPremium20
5USStandard15
6INBasic8
7USPremium20
8DEStandard15
9BRBasic8
10FRStandard15

Previewing 10 of 11 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

SQL Interview Practice

Return to the complete interview preparation experience.