SQL QuestSQL Interview Questions › Aggregation & Grouping

Movie Title Initial Letter Histogram (SUBSTR)

EasyFreeQuerying BasicsAggregation & GroupingString Functions

A library-style index wants a histogram of movie titles by their first letter. Group movies by UPPER(SUBSTR(title, 1, 1)) so 'a' and 'A' bucket together.

Show initial and movie_count. Order by initial.

The UPPER is a defensive normalization — most titles start with capitals, but mixed casing in source data is the kind of subtle bug that shows up in production after a content team imports something messy.

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: A → 2, B → 1

Hint

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

Concepts

SELECT GROUP BY SUBSTR String Functions

Practise the topic: SQL practice questions · GROUP BY exercises · String function practice

Related questions

Counting RowsEasy · FreeSUM, AVG, MIN, MAXEasy · FreeGROUP BY BasicsEasy · FreeMonthly Order CountEasy · FreeHow Many Genres Do We Cover? (DISTINCT)Easy · FreeFemale Survivor CountEasy · 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