반응형
www.hackerrank.com/challenges/the-pads/problem
The PADS | HackerRank
Query the name and abbreviated occupation for each person in OCCUPATIONS.
www.hackerrank.com
해결 방법 : CONCAT, SUBSTR 함수
- CONCAT(str1, str2, ...) : 문자열 합치기
- SUBSTR(문자열, 첫 인덱스, 문자 개수) : 문자열 자르기
SELECT concat(name, '(', substr(occupation, 1, 1), ')')
FROM occupations
ORDER BY name;
SELECT concat('There are a total of ', count(occupation), ' ', lower(occupation), 's.')
FROM occupations
GROUP BY occupation
ORDER BY count(occupation), occupation;
반응형
'IT study > SQL' 카테고리의 다른 글
New Companies (+ 형 변환) (0) | 2021.04.22 |
---|---|
Binary Tree Nodes (0) | 2021.04.18 |
Occupations (SET, CASE) (0) | 2021.04.17 |
15 days of learning SQL (0) | 2021.04.15 |
Interviews (0) | 2021.04.15 |