AnalystPath

Title-Case Recipe Names With Hyphens

SQLHardSenior level~15 min

Problem

A recipe site stores names in inconsistent casing. Convert each `raw_title` to title case: the first letter of every word becomes uppercase and the remaining letters of the word become lowercase. A word may contain hyphens, and each hyphen-separated part must also be capitalized — for example `slow-cooked` becomes `Slow-Cooked`. Spaces, hyphens, and all other characters stay exactly where they are. Return `recipe_id`, the unchanged title as `original_title`, and the converted text as `title_cased`, ordered by `recipe_id`.

Tables

Example rows — the live problem includes the full dataset.

recipe_titles
recipe_idraw_title
1creamy tomato BASIL soup
2the SLOW-cooked stew
3pan-seared SALMON fillet

Expected output

Your answer should return 4 rows with the columns recipe_id, original_title, title_cased.

Starter code (SQL)

SELECT *
FROM recipe_titles;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions