일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 정치학
- 맛집
- 자료구조
- 후기
- Great Minds
- 누가 진정한 리더인가
- K-MOOC
- MySQL
- python
- 위대한 수업
- Progate
- Joseph Samuel Nye Jr.
- Baekjoon
- Udemy
- 빅데이터
- 당신이 몰랐던 진화론
- 알고리즘
- ADsP
- 조지프 나이
- EBS
- ADP
- 미분적분학
- CNN10
- 백준
- 데이터분석전문가
- 데이터분석전문가가이드
- 공부정리
- 코테
- Hacker Rank
- KMOOC
Archives
- Today
- Total
ㅇ
[Hacker Rank_MySQL]문제 풀이#The PADS 본문
SQL > Advanced Select > The PADS
The PADS | HackerRank
Query the name and abbreviated occupation for each person in OCCUPATIONS.
www.hackerrank.com
1. Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S).
2. Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format: There are a total of [occupation_count] [occupation]s.
빨간 글씨는 내가 문제를 풀 때 중요하다고 생각한 부분이다.
두 쿼리를 연달아 작성할 때, 세미콜론으로 앞 쿼리가 끝났다는 것을 표시해야 한다.
이게 없어서 한참 다른 사람들 코드를 찾아봤다.
SELECT CONCAT(NAME,'(', SUBSTR(OCCUPATION, 1, 1), ')')
FROM OCCUPATIONS
ORDER BY NAME ASC;
SELECT CONCAT('There are a total of ', COUNT(OCCUPATION), ' ', LOWER(OCCUPATION), 's.')
FROM OCCUPATIONS
GROUP BY OCCUPATION
ORDER BY COUNT(OCCUPATION) ASC, OCCUPATION ASC
반응형
'IT > 코테문제' 카테고리의 다른 글
[Hacker Rank_MySQL]문제 풀이#Binary Tree Nodes (0) | 2022.03.01 |
---|---|
[Hacker Rank_MySQL]문제 풀이#Weather Observation Station 19 (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#Challenges (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#Top Earners (0) | 2022.02.28 |
[Hacker Rank_MySQL]문제 풀이#Ollivander's Inventory (0) | 2022.02.27 |
Comments