https://school.programmers.co.kr/learn/courses/30/lessons/59043
SELECT I.ANIMAL_ID, I.NAME
FROM ANIMAL_INS I
JOIN (
SELECT ANIMAL_ID, DATETIME
FROM ANIMAL_OUTS
) AS O
ON I.ANIMAL_ID = O.ANIMAL_ID
WHERE I.DATETIME > O.DATETIME
ORDER BY I.DATETIME ASC;