코딩테스트/HackerRank

[Advanced select] The PADS(Oracle)

봉두두 2022. 4. 22. 23:29
728x90

We Do not allow non ASCII characters for this challenge 와 같은 유사한 오류문구가 출력됐었는데,

아직 언제 이런 오류가 뜨는건지는 잘 모르겠다.

어쨌든 아래는 처음에 안되었지만.. 다시해보니 성공한 query이다.

concatsubstr, lower를 테스트하는 문제였던 것 같다.

아 그리고 또 한가지.

두가지 결과를 얻고자 할때 union(all)을 사용하지 않아도 자동으로 두 쿼리문의 결과를 union해서 판정한다.

-- Hackerrank_The PADS (https://www.hackerrank.com/challenges/the-pads/problem?isFullScreen=true)
-- SQL(Intermediate)
select name || '(' || substr(occupation,1,1) || ')'
from occupations
order by name;

select 'There are a total of ' || count(*) || ' ' || lower(occupation) || 's.'
from occupations
group by occupation
order by count(*), occupation;
728x90
728x90