AnalystPath

Tidy Up Author Names

SQLEasyJunior level~15 min

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
author_idpen_name
1aLICE
2BORIS
3cora

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

Related SQL questions