본문 바로가기

Database/SQL

Hackerrank / 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

 

# MySQL

select CONCAT(NAME,'(', SUBSTR(Occupation,1,1),')')
from OCCUPATIONS 
order by Name;

select CONCAT('There are a total of ', A.oc_cnt, ' ', lower(A.Occupation),'s.')
from (select Occupation, count(Occupation) as oc_cnt from OCCUPATIONS 
      group by Occupation order by oc_cnt, Occupation) A;

 

MySQL은 문장을 생성할 때 (+) 기호 사용이 불가능하다.

'Database > SQL' 카테고리의 다른 글

Hackerrank / Ollivander's Inventory  (0) 2022.01.22
Hackerrank / The Report  (0) 2022.01.22
Hackerrank / New Companies  (0) 2021.12.03
Hackerrank / Binary Tree Nodes  (0) 2021.12.03
Hackerrank / OCCUPATIONS  (0) 2021.11.30