Normalize Ingredient Names to Title Case
Problem
A recipe app imports ingredient lines from many messy sources, so the casing is inconsistent. Write a solution that rewrites the raw_line column into title case: the first letter of every word becomes uppercase and every other letter becomes lowercase. Words are separated by single spaces, and all existing spaces must be preserved exactly. Return entry_id, raw_line aliased as raw_line, and the cleaned value aliased as tidy_line.
Tables
Example rows — the live problem includes the full dataset.
| entry_id | raw_line |
|---|---|
| 1 | two cups of FLOUR |
| 2 | one TEASPOON sea salt |
| 3 | fresh basil AND ripe tomato |
Expected output
Your answer should return 4 rows with the columns entry_id, raw_line, tidy_line.
Starter code (SQL)
SELECT *
FROM ingredient_lines;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