Description
Write a SQL query to fix names so only first letter is uppercase and rest are lowercase. Return user_id and fixed name.
Table:
users| Column | Type |
|---|---|
| user_id | INT |
| name | TEXT |
Examples
Input:
CREATE TABLE users (user_id INT, name TEXT); INSERT INTO users VALUES (1, 'aLICE'), (2, 'BOB');Output:
1|Alice
2|BobExplanation:
Names are fixed to proper capitalization: 'aLICE' becomes 'Alice' and 'BOB' becomes 'Bob'.
Input:
CREATE TABLE users (user_id INT, name TEXT); INSERT INTO users VALUES (4, 'DAVID'), (5, 'emma'), (6, 'FrAnK');Output:
4|David
5|Emma
6|FrankExplanation:
Names are fixed by capitalizing only the first letter and making all other letters lowercase. 'DAVID' becomes 'David', 'emma' becomes 'Emma', and 'FrAnK' becomes 'Frank'.
Input:
CREATE TABLE users (user_id INT, name TEXT); INSERT INTO users VALUES (7, 'grace'), (8, 'HENRY'), (9, 'iVY');Output:
7|Grace
8|Henry
9|IvyExplanation:
The query transforms each name to proper case format where only the first character is uppercase. 'grace' starts lowercase and becomes 'Grace', 'HENRY' is all uppercase and becomes 'Henry', and 'iVY' has mixed case and becomes 'Ivy'.
Constraints
- •
Use UPPER and LOWER functions