SQL QuestSQL Interview Questions › String Functions

Long-Named Passengers

EasyFreeQuerying BasicsString Functions

The memorial plaque engraver needs to size name plates. Find passengers whose name is longer than 30 characters. Show name, name_length (the character count of the name), and pclass. Sort by name_length descending, with name ascending as a tie-breaker.

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

passengers

passenger_idsurvivedpclassnamesexagesibspparchfareembarked
103Braund, Mr. Owen Harrismale22107.25S
211Cumings, Mrs. John Bradleyfemale381071.28C
313Heikkinen, Miss. Lainafemale26007.93S

Expected output: Names > 30 chars, longest first

Hint

LENGTH(name) returns character count in SQLite. Use it in both WHERE (LENGTH(name) > 30) and SELECT (LENGTH(name) AS name_length). Alias the computed column so ORDER BY can reference it.

Concepts

SELECT String Functions LENGTH WHERE ORDER BY

Practise the topic: SQL practice questions · String function practice

In these company practice sets

Google · Snowflake

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

Related questions

Employee Display Cards (Concat)Easy · FreeCountry Codes in UppercaseEasy · FreeExtract Family Names (SUBSTR + INSTR)Easy · FreeYear Code from Order Date (SUBSTR)Easy · FreeMovie Title Initial Letter Histogram (SUBSTR)Easy · FreePosition of '@' in Email (INSTR)Easy · 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