문제/프로그래머스_sql
20. 보호소에서 중성화한 동물
sm_hope
2022. 10. 25. 18:24
SELECT ins.ANIMAL_ID, ins.ANIMAL_TYPE, ins.NAME
from ANIMAL_INS AS ins
left join ANIMAL_OUTS AS outs
on ins.ANIMAL_ID = outs.ANIMAL_ID
where ins.SEX_UPON_INTAKE like "%Intact%"
and (outs.SEX_UPON_OUTCOME like "%Spayed%" or outs.SEX_UPON_OUTCOME like "%Neutered%")
order by ins.ANIMAL_ID
문제
: 들어올 때는 intract 였으나 나갈 때는 spayed 혹은 neutered인 동물들을 id순으로 조회하라.