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
'🛠️Skill > CodingTest' 카테고리의 다른 글
[프로그래머스] Lv2.조건에 맞는 도서와 저자 리스트 출력/Lv3. 카테고리 별 도서 판매량 집계 (0) | 2022.12.16 |
---|---|
[프로그래머스] LV4. 자동차 대여 기록 별 대여 금액 구하기 / DATEDIFF (0) | 2022.12.14 |
[프로그래머스]Lv5. 상품을 구매한 회원 비율 구하기 (0) | 2022.12.06 |
[프로그래머스] Lv3. 오랜 기간 보호한 동물(1) (2) / LEFT JOIN (0) | 2022.12.05 |
[프로그래머스] Lv3. 있었는데요 없었습니다 / 없어진 기록 찾기 (0) | 2022.12.01 |
댓글