Netflix-style Company ChallengeEasyVerified answerSQLite live

Subscribers per Plan

Return plan and the number of subscribers on each plan, ordered by subscriber_count descending.

  • Aggregation
  • Sorting

Challenge brief

Understand the request

Product — Subscription Tiers The product team is evaluating plan popularity to decide whether to adjust tier pricing.

Count how many subscribers are on each plan.

Return

  • plan
  • subscriber_count

Constraints

  • Return one row per subscription plan
  • Order by subscriber count descending, then plan

Data you will use

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

subscriptions

  • subscription_idINTEGER
  • 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

Subscription plan is the reporting grain.

Hint 2

Count subscription rows within each plan.

Hint 3

Use the metric and plan label as the ordering levels.

Verified SQL answer

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

Reveal solution and explanation
SELECT plan, COUNT(*) AS subscriber_count FROM subscriptions GROUP BY plan ORDER BY subscriber_count DESC, plan

Why this works

GROUP BY plan aggregates subscription rows by tier. COUNT(*) gives the subscriber count per plan. The secondary ORDER BY plan resolves the tie between Standard and Premium (both 3).

Success check

Returns the complete deterministic result for subscribers per plan

Expected result

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

plansubscriber_count
Standard4
Basic3
Premium3

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.