App Category Performance Analysis
For each App Store category with at least 5 million total downloads, show total downloads, average rating, app count, and rank by download volume.
- Window functions
- Aggregation
- HAVING
- Numeric functions
- Sorting
Challenge brief
Understand the request
App Store Analytics is preparing the annual App Store Trends report and needs download volume and quality metrics by category.
Analyse App Store performance by category — total downloads, average rating, app count, and RANK() by download volume.
Return
- category
- total_downloads
- avg_rating (rounded 2)
- app_count
- category_rank (RANK by total_downloads desc)
Constraints
- Return categories with at least 5 million downloads
- Categories with equal downloads share a rank
- Resolve display ties by category
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
app_store_apps
app_idINTEGERcategoryVARCHAR(50)downloadsINTEGERratingREAL
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
All data is in app_store_apps. Single-table aggregation: GROUP BY category, SUM(downloads), AVG(rating), COUNT(app_id). Add HAVING SUM >= 5000000. RANK() OVER for the rank.
Hint 2
GROUP BY category. SUM(downloads) AS total_downloads. ROUND(AVG(rating), 2). COUNT(app_id). HAVING SUM(downloads) >= 5000000. RANK() OVER (ORDER BY SUM(downloads) DESC).
Hint 3
Build question 9 from its business grain: identify the driving rows, add only valid relationships, then apply the required filtering, aggregation, and deterministic ordering.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT category, SUM(downloads) AS total_downloads, ROUND(AVG(rating), 2) AS avg_rating, COUNT(app_id) AS app_count, RANK() OVER (ORDER BY SUM(downloads) DESC) AS category_rank FROM app_store_apps GROUP BY category HAVING SUM(downloads) >= 5000000 ORDER BY total_downloads DESC, category;Why this works
Single-table GROUP BY. RANK() runs after aggregation so it ranks grouped sums. All 10 app categories in the dataset have >= 5M downloads so all qualify. Entertainment has 3 apps (TikTok, Netflix, YouTube) summing to 125M.
Success check
10 categories qualify — Entertainment leads (125M downloads), Health is last at 9M. Games and Health categories fall below 5M threshold would be excluded, but here both qualify.
Expected result
Use this output to verify values, aliases, ordering, and row count.
| category | total_downloads | avg_rating | app_count | category_rank |
|---|---|---|---|---|
| Entertainment | 125000000 | 4.5 | 3 | 1 |
| Social | 95000000 | 4.75 | 2 | 2 |
| Music | 35000000 | 4.9 | 1 | 3 |
| Games | 34000000 | 4.05 | 2 | 4 |
| Education | 25000000 | 4.7 | 1 | 5 |
| Travel | 20000000 | 4.2 | 1 | 6 |
| Productivity | 18000000 | 4.6 | 1 | 7 |
| Business | 15000000 | 4.3 | 1 | 8 |
| Graphics | 14000000 | 4.65 | 2 | 9 |
| Health | 9000000 | 4.8 | 1 | 10 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Microsoft
Independent Microsoft-style cloud, productivity, subscription, usage, support, and customer analytics 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.