링크
https://leetcode.com/problems/fix-names-in-a-table/
문제
Write a solution 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 result format is in the following example.
정답
select user_id,
concat(upper(substr(name, 1, 1)), lower(substr(name, 2, length(name)))) as name
from users
order by user_id
해설
- upper: 문자를 대문자로 변환
- lower: 문자를 소문자로 변환
- substr: 특정 위치에 문자를 추출
- concat: 문자를 결합
'[업무 지식] > MySQL' 카테고리의 다른 글
[delete] Delete Duplicate Emails (0) | 2024.11.14 |
---|---|
[LIKE] Patients With a Condition (0) | 2024.11.14 |
[row/between] 프레임 정의 (0) | 2024.11.12 |
[WINDOW] Restaurant Growth (0) | 2024.11.11 |
[LAG, LEAD] Exchange Seats (0) | 2024.11.08 |