728x90
테이블 생성코드
Create table If Not Exists Users (user_id int, name varchar(40))
Truncate table Users
insert into Users (user_id, name) values ('1', 'aLice')
insert into Users (user_id, name) values ('2', 'bOB')
문제
풀이코드
SELECT user_id, concat(upper(left(name,1)), lower(substring(name,2))) AS name
FROM Users
ORDER BY user_id;
해설
첫글자는 개문자, 나머지는 소문자로 출력해야 하므로
name의 첫글자를 대문자로 만든것과 name의 2번째부터 나머지를 소문자로 만든것을 concat하여 출력하고
user_id를 기준으로 order by 정렬한다.
728x90
'• data analysis > SQL' 카테고리의 다른 글
1633. Percentage of Users Attended a Contest (0) | 2024.02.28 |
---|---|
1075. Project Employees I (0) | 2024.02.26 |
610. Triangle Judgement (0) | 2024.02.24 |
1068. Product Sales Analysis I (0) | 2024.02.22 |
[leetcode] 1148. Article Views I (0) | 2024.02.20 |