SQLite/solvesql 작품이 없는 작가 찾기

[SQLite/solvesql] 작품이 없는 작가 찾기

📌문제링크

살아있지 않은 작가중 MoMa에 등록된 작품이없는 작가의 id와 이름을 출력하면된다.


solution

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
select
  Death.artist_id,
  Death.name
from
  (
    select
      artist_id,
      name
    from
      artists
    where
      death_year is not null
  ) Death -- death_artist
  left outer join artworks_artists Work on Work.artist_id = Death.artist_id
where
  Work.artwork_id is null