코딩 연습/SQL

인프런: SQL 중급 문제 풀이

썬2 2022. 7. 16. 23:39

https://www.hackerrank.com/challenges/the-company/problem

 

New Companies | HackerRank

Find total number of employees.

www.hackerrank.com

포인트: 여러 join문으로 연결하기

select C.company_code,
       C.founder,
       count(distinct(LM.lead_manager_code)),
       count(distinct(SM.senior_manager_code)),
       count(distinct(M.manager_code)),
       count(distinct(E.employee_code))
from Company C
    left join Lead_Manager LM on C.company_code = LM.company_code
    left join Senior_Manager SM on LM.lead_manager_code = SM.lead_manager_code
    left join Manager M on SM.senior_manager_code = M.senior_manager_code
    left join Employee E on M.manager_code = E.manager_code
group by C.company_code, C.founder
order by C.company_code

 

 

https://www.hackerrank.com/challenges/weather-observation-station-11/problem

 

Weather Observation Station 11 | HackerRank

Query a list of CITY names not starting or ending with vowels.

www.hackerrank.com

포인트: startswith, endwith

select distinct city
from STATION
where left(city, 1) not in ('A', 'E', 'I', 'O', 'U')
or right(city, 1) not in ('A', 'E', 'I', 'O', 'U')

 

between 하면 >= and <=

 

 

'코딩 연습 > SQL' 카테고리의 다른 글

leetcode 196. delete duplicate emails  (0) 2022.08.09
leetcode 627 swap salary  (0) 2022.08.09
[leetcode] 595 ~  (0) 2022.04.21
[leetcode] 570 ~ 586  (0) 2022.04.18
[leetcode] 262 ~ 569  (0) 2022.04.13