Video Views Per Category
How many total video views has each YouTube content category received?
- Joins
- Aggregation
- Sorting
Challenge brief
Understand the request
Video Content Strategy is reviewing content category performance to guide recommendation algorithm tuning.
Return category, views in the declared deterministic order.
Return
- category
- views
Constraints
- Count view records for every represented video category
- Order by view count descending, then category
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
video_views
view_idINTEGERuser_idINTEGERvideo_idINTEGERview_dateDATEwatch_timeINTEGER
videos
video_idINTEGERtitleVARCHAR(200)categoryVARCHAR(50)
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
Video category comes from the catalog while view facts contain the counted events.
Hint 2
Connect the tables at video grain before grouping by category.
Hint 3
Order category totals using both the metric and label.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT v.category, COUNT(*) AS views FROM video_views vv INNER JOIN videos v ON vv.video_id = v.video_id GROUP BY v.category ORDER BY views DESC, v.categoryWhy this works
Each row in video_views is one view event. After joining to videos for the category label, COUNT(*) per category gives total views. Education has 15 views because the dataset contains many Education videos (Python tutorial, ML basics, etc.) that attract multiple viewers.
Success check
Returns the complete deterministic result for video views per category
Expected result
Use this output to verify values, aliases, ordering, and row count.
| category | views |
|---|---|
| Education | 15 |
| Finance | 4 |
| Food | 4 |
| Technology | 4 |
| Travel | 4 |
| Gaming | 3 |
| Entertainment | 2 |
| Health | 2 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Meta
Independent Meta-style social-product, engagement, content, community, messaging, and advertising SQL practice.
Microsoft
Independent Microsoft-style cloud, productivity, subscription, usage, support, and customer analytics SQL practice.
Netflix
Independent Netflix-style streaming, subscription, catalog, ratings, and engagement SQL practice.
Return to the complete interview preparation experience.