Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 패스트캠퍼스
- 파이썬을활용한시계열데이터분석AtoZ올인원패키지Online
- join
- SELF-JOIN
- 직장인자기계발
- 다시풀어보기
- lv.4
- 해커랭크
- 패캠챌린지
- HACKER_RANK
- 프리미엄
- LeetCode
- row_number
- medium
- 직장인인강
- meidum
- SQL
- recursive
- MySQL
- 파이썬을활용한시계열데이터분석
- Hackerrank
- easy
- solvesql
- 패스트캠퍼스후기
- group by
- Hard
- RANK
- 어려웠음
- 프로그래머스
- 시계열데이터분석
Archives
- Today
- Total
~고군분투 인생살이~
[1667] Fix Names in a Table 본문
Fix Names in a Table - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
Table: Users
+----------------+---------+
| Column Name | Type |
+----------------+---------+
| user_id | int |
| name | varchar |
+----------------+---------+
user_id is the primary key for this table.
This table contains the ID and the name of the user. The name consists of only lowercase and uppercase characters.
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.
Example 1:
Input:
Users table:
+---------+-------+
| user_id | name |
+---------+-------+
| 1 | aLice |
| 2 | bOB |
+---------+-------+
Output:
+---------+-------+
| user_id | name |
+---------+-------+
| 1 | Alice |
| 2 | Bob |
+---------+-------+
문제 조건
- 첫 글자는 대문자 나머지는 소문자로 변화
SELECT user_id
,CONCAT(UPPER(LEFT(name,1)),LOWER(SUBSTRING(name,2))) AS name
FROM Users
ORDER BY user_id
# INITCAP은 MySQL에서 지원하지 않음
'SQL > LEETCODE' 카테고리의 다른 글
[1174#_MEDIUM] Immediate Food Delivery II (0) | 2022.07.22 |
---|---|
[1164#_MEDIUM] Product Price at a Given Date (0) | 2022.07.22 |
[1661#_EASY] Average Time of Process per Machine (0) | 2022.07.22 |
[1633#_EASY] Percentage of Users Attended a Contest (0) | 2022.07.22 |
[1158] Market Analysis I (0) | 2022.07.20 |
Comments