SQL QuestSQL Interview Questions › Subqueries & CTEs

Movies Rated Above the Average

EasyFreeQuerying BasicsSubqueries & CTEs

The programming desk wants a shortlist of everything rated above the average of the whole table — not above 8, not above a number somebody remembered, above whatever the average happens to be.

Show exactly these 3 columns, in this order: title, genre, rating. No aliases, no rounding — rating is already the stored value. Include every movie whose rating is strictly greater than the average rating across all movies. Order by rating descending, then title ascending.

The idea: (SELECT AVG(rating) FROM movies) inside your WHERE runs first, collapses to a single number, and your > compares against that number. You met this shape on salaries; it is the same shape here, on a table you already know.

Why not look the average up once and paste it in? Because the moment one rating changes, your literal is wrong and the query still runs — returning a confidently wrong list.

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: 61 rows — every movie above 7.772, best first

Hint

The hint for this one spells out most of the query, so it stays in the editor. Reach for SELECT, Subquery, WHERE, and open the hint there if you stall.

Concepts

SELECT Subquery WHERE

Practise the topic: SQL practice questions · CTE practice

Related questions

A Subquery That Returns One ValueEasy · FreeA Subquery That Returns a Set (IN)Easy · FreeGive a Query a Name (WITH)Easy · FreeEvery Film by a Director Who Once Hit 8.5Easy · FreeFilter on an Average You Just ComputedEasy · FreeBetter Than Its Own GenreEasy · 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