Skip to content
We areTOP 1%

Fix Names in a Table

EasyLeetCodeSQL: CASE, String & Date Functions
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Hint and exampleShow

Split the text into its first character and the rest with LEFT and SUBSTRING, change the case of each part, and join them with CONCAT.

Example: cities(id, city)

id | city
1  | pUNE
2  | delhi
SELECT id,
       CONCAT(UPPER(LEFT(city, 1)), LOWER(SUBSTRING(city, 2))) AS city
FROM cities
ORDER BY id;   -- 1 | Pune, 2 | Delhi

More in SQL: CASE, String & Date Functions

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account