본문 바로가기

개발/sql

프로그래머스_헤비유저가 소유한 장소 HAVING절 사용(left outer join)

 

1. 헤비유저를 찾는 구절

select 
host_id
from places
group by host_id
having count(host_id)>1

2. join을 사용해 결과출력

select a.id, a.name, a.host_id
from places a
right outer join 
    (select host_id
    from places
    group by host_id
    having count(host_id)>1) b
on a.host_id=b.host_id

참고 https://haenny.tistory.com/34

3. 결과