안녕하세요!
이번 포스팅은 LeetCode에 있는 Fix Names in a Table 문제를 OracleDB로 풀어보려고 합니다!
(모든 문제는 Oracle로 풀이하겠습니다.)
1. 문제 링크 : https://leetcode.com/problems/fix-names-in-a-table/description/
2. 문제
| Column name | Type |
| user_id | int |
| name | varchar |
[문제] Write a solution to fix the names so that only the first character is uppercase and the rest are lowercase.
첫 글자만 대문자로 하고 나머지 글자는 소문자로 수정하는 문제입니다.
3. 제출 쿼리 및 설명
최종) CONCAT(문자열 합치기), SUBSTR(문자열 나누기)라는 문자열 함수와 UPPER(대문자로 변환), LOWER(소문자로 변환) 함수를 활용해서 첫 글자만 대문자로 하고 나머지 글자는 소문자로 수정합니다.
SELECT
USER_ID,
CONCAT(UPPER(SUBSTR(NAME, 1, 1)), LOWER(SUBSTR(NAME, 2))) AS NAME
FROM USERS
ORDER BY USER_ID
;
'SQL > LeetCode' 카테고리의 다른 글
| [SQL] Daily Leads and Partners(LeetCode/Oracle) (0) | 2023.10.26 |
|---|---|
| [SQL] Invalid Tweets(LeetCode/Oracle) (0) | 2023.10.26 |
| [SQL] Average Time of Process per Machine(LeetCode/Oracle) (0) | 2023.10.26 |
| [SQL] Percentage of Users Attended a Contest(LeetCode/Oracle) (0) | 2023.10.26 |
| [SQL] Bank Account Summary II(LeetCode/Oracle) (0) | 2023.10.26 |