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_idINTEGERuser_idINTEGERplanVARCHAR(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, planWhy 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.
| plan | subscriber_count |
|---|---|
| Standard | 4 |
| Basic | 3 |
| Premium | 3 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Google
Independent Google-style search, advertising, user-engagement, and video-product SQL practice.
Meta
Independent Meta-style social-product, engagement, content, community, messaging, and advertising SQL practice.
Airbnb
Independent Airbnb-style marketplace, booking, listing, payment, review, and guest analytics SQL practice.
Return to the complete interview preparation experience.