정답
1. 없어진 기록 찾기
1
2
3
4
select A.ANIMAL_ID, A.NAME
from ANIMAL_OUTS as A left join ANIMAL_INS as B on A.ANIMAL_ID = B.ANIMAL_ID
where B.ANIMAL_ID is null
order by A.ANIMAL_ID;
2. 있었는데요 없었습니다
1
2
3
4
select A.ANIMAL_ID, A.NAME
from ANIMAL_INS as A left join ANIMAL_OUTS B on A.ANIMAL_ID = B.ANIMAL_ID
where A.DATETIME > B.DATETIME
order by A.DATETIME;
3. 오랜 기간 보호한 동물(1)
1
2
3
4
5
select A.NAME, A.DATETIME
from ANIMAL_INS as A left join ANIMAL_OUTS as B on A.ANIMAL_ID = B.ANIMAL_ID
where B.ANIMAL_ID is null
order by A.DATETIME asc
limit 0,3;
4. 보호소에서 중성화한 동물
1
2
3
4
5
6
select A.ANIMAL_ID, A.ANIMAL_TYPE, A.NAME
from ANIMAL_INS as A left join ANIMAL_OUTS as B on A.ANIMAL_ID = B.ANIMAL_ID
where A.ANIMAL_ID = B.ANIMAL_ID
and A.SEX_UPON_INTAKE like 'Intact%'
and B.SEX_UPON_OUTCOME not like 'Intact%'
order by A.ANIMAL_ID;