본문 바로가기
HackerRank

해커랭크 The PADS

by 콩순이냉장고 2022. 12. 15.

문제 URL : https://www.hackerrank.com/challenges/the-pads/problem?isFullScreen=true&h_r=next-challenge&h_v=zen 

 

The PADS | HackerRank

Query the name and abbreviated occupation for each person in OCCUPATIONS.

www.hackerrank.com

 

문제 설명 : 문제가 2개인거다

첫번째는 occupations 테이블에 이름+(직업이름 첫단어)

두번째는 There are a total of [occupation_count] [occupation]s. 를구하는문제입니다.

concat과 substr, 혹은 substring, 혹은 left 를 사용하는 문제인데

직업의 첫단어이니 저는left를 사용해봤네요

 

select concat(name,'(',left(occupation,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