728x90
[해커랭크] The PADS
https://www.hackerrank.com/challenges/the-pads/problem?isFullScreen=true
The PADS | HackerRank
Query the name and abbreviated occupation for each person in OCCUPATIONS.
www.hackerrank.com
문제)
- 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).
- Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format:
There is a total of [occupation_count], [occupation]s.
where [occupation_count] is the number of occurrences of an occupation in OCCUPATIONS and [occupation] is the lowercase occupation name. If more than one Occupation has the same [occupation_count], they should be ordered alphabetically.
select concat(name, '(', substr(occupation, 1, 1), ')')
from occupations
order by name asc;
select concat('There are a total of ', count(name), ' ', lower(occupation), 's.')
from occupations
group by occupation
order by count(name);
728x90
'SQL' 카테고리의 다른 글
[해커랭크] Weather Observartion Station 19 (0) | 2023.07.21 |
---|---|
[해커랭크] Weather Observation Station 18 (0) | 2023.07.21 |
[해커랭크] Draw The Triangle 2 (0) | 2023.07.20 |
[해커랭크] Draw The Triangle 1 (0) | 2023.07.20 |
[해커랭크] Top Earners (0) | 2023.07.18 |