Tidy Up Author Names
Problem
Table: `author`
| Column Name | Type |
|---|---|
| author_id | int |
| pen_name | varchar |
`author_id` is the primary key. `pen_name` consists only of lowercase and uppercase English letters and was entered with inconsistent capitalization.
Write a query that normalizes each `pen_name` so that only the first letter is uppercase and every other letter is lowercase. Keep the alias `pen_name`. Return the result ordered by `author_id` ascending.
Tables
Example rows — the live problem includes the full dataset.
| author_id | pen_name |
|---|---|
| 1 | aLICE |
| 2 | BORIS |
| 3 | cora |
Expected output
Your answer should return 3 rows with the columns author_id, pen_name.
Starter code (SQL)
SELECT *
FROM author;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