The Fix Names in a Table interview question is a SQL string formatting task. You are given a Users table with a name column. The names are stored inconsistently (e.g., "aLICE", "BOB"). You need to write a query that returns the names formatted such that only the first character is uppercase and the rest are lowercase.
Companies like Microsoft and Amazon use the Fix Names coding problem to test basic string manipulation functions in SQL. Data normalization is a critical part of database management, and being able to clean strings using UPPER, LOWER, SUBSTRING, and CONCAT is a foundational skill.
This problem follows the SQL String Concatenation pattern.
SUBSTR(name, 1, 1) and apply UPPER().SUBSTR(name, 2) and apply LOWER().CONCAT() or the || operator to join the two parts.aLICEUPPER(SUBSTR('aLICE', 1, 1)) -> 'A'LOWER(SUBSTR('aLICE', 2)) -> 'lice'BOBUPPER('B') -> 'B'LOWER('OB') -> 'ob'SUBSTR indices (some SQL dialects are 1-indexed, others are 0-indexed).+ in SQL Server vs || in PostgreSQL).Familiarize yourself with string functions in major SQL dialects (MySQL, PostgreSQL, T-SQL). Knowing that SUBSTRING and LENGTH exist is usually enough, but knowing the exact syntax for the requested dialect shows you are well-prepared.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Not Boring Movies | Easy | Solve | |
| Primary Department for Each Employee | Easy | Solve | |
| Queries Quality and Percentage | Easy | Solve | |
| Combine Two Tables | Easy | Solve | |
| Customers Who Never Order | Easy | Solve |