SQL QuestSQL Interview Questions › Subqueries & CTEs

Highest Rated by Genre

MediumFreeSubqueries & CTEsAggregation & GroupingQuerying Basics

Find the highest rated movie in each genre. Return the title, genre, and rating. Only include genres with at least 2 movies. Order by rating descending.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

movies

idtitleyeargenreratingvotesrevenue_millionsruntimedirector
1Guardians of the Galaxy2014Action8.1757074333.13121James Gunn
2Prometheus2012Adventure7485820126.46124Ridley Scott
3Split2016Horror7.3157606138.12117M. Night Shyamalan

Expected output: Action | Movie A | 8.9

Hint

Use a subquery to find MAX(rating) per genre, then match back to the movies table

Concepts

Subqueries Aggregation WHERE GROUP BY HAVING

Practise the topic: CTE practice · GROUP BY exercises · SQL practice questions

In these company practice sets

Netflix · Snowflake · Spotify

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Department Roster with GROUP_CONCATMedium · FreeConsistent Director AnalysisMedium · FreeBelow Department AverageMedium · FreeHighest Total Salary Budget DepartmentMedium · FreeFare Imputation AnalysisMedium · FreeUNION ALL Dedup: Cross-Dataset SearchMedium · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test