Skip to content

Commit 17fabaf

Browse files
authored
Merge pull request #51 from iamAntimPal/Branch-1
1667. Fix Names in a Table
2 parents 404bdb3 + 39d9bdb commit 17fabaf

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
1667. Fix Names in a Table
2+
Solved
3+
Easy
4+
Topics
5+
Companies
6+
SQL Schema
7+
Pandas Schema
8+
Table: Users
9+
10+
+----------------+---------+
11+
| Column Name | Type |
12+
+----------------+---------+
13+
| user_id | int |
14+
| name | varchar |
15+
+----------------+---------+
16+
user_id is the primary key (column with unique values) for this table.
17+
This table contains the ID and the name of the user. The name consists of only lowercase and uppercase characters.
18+
19+
20+
Write a solution to fix the names so that only the first character is uppercase and the rest are lowercase.
21+
22+
Return the result table ordered by user_id.
23+
24+
The result format is in the following example.
25+
26+
27+
28+
Example 1:
29+
30+
Input:
31+
Users table:
32+
+---------+-------+
33+
| user_id | name |
34+
+---------+-------+
35+
| 1 | aLice |
36+
| 2 | bOB |
37+
+---------+-------+
38+
Output:
39+
+---------+-------+
40+
| user_id | name |
41+
+---------+-------+
42+
| 1 | Alice |
43+
| 2 | Bob |
44+
+---------+-------+
45+
46+
47+
48+
49+
# Write your MySQL query statement below
50+
SELECT user_id,
51+
CONCAT(UPPER(LEFT(name, 1)), LOWER(SUBSTRING(name, 2))) AS name
52+
FROM Users
53+
ORDER BY user_id;

0 commit comments

Comments
 (0)