LeetCode - 1667. Fix Names in a Table (MySQL)

조민수·2024년 6월 20일
0

LeetCode

목록 보기
39/61

Easy, SQL - SUBSTR, LEFT, UPPER

RunTime : 715 ms


문제

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.


풀이

  • STRING처리하는 문제, SUBSTR은 써봤었는데 나머지는 처음이었다.
  • LEFT(col, x)는 왼쪽부터 x개 문자를 가져온다.
SELECT user_id,
CONCAT(UPPER(LEFT(name, 1)), LOWER(SUBSTR(name, 2, LENGTH(name) - 1))) as name FROM Users
ORDER BY user_id
profile
사람을 좋아하는 Front-End 개발자

0개의 댓글