🛠️Skill/CodingTest
[leetcode] 1667. Fix Names in a Table / CONCAT, SUBSTRING
Istj_eff
2022. 12. 12. 16:28
1667. Fix Names in a Table
https://leetcode.com/problems/fix-names-in-a-table/
Fix Names in a Table - LeetCode
Can you solve this real interview question? Fix Names in a Table - Table: Users +----------------+---------+ | Column Name | Type | +----------------+---------+ | user_id | int | | name | varchar | +----------------+---------+ user_id is the primary key fo
leetcode.com
Write an SQL query to fix the names so that only the first character is uppercase and the rest are lowercase.
Return the result table ordered by user_id.
The query result format is in the following example.
첫 번째 문자만 대문자로, 나머지는 소문자로 변경
답
SELECT user_id
, CONCAT(UPPER(SUBSTRING(name, 1, 1))
, LOWER(SUBSTRING(name, 2, LENGTH(name)))) AS name
FROM Users
ORDER BY user_id