SQL

[프로그래머스] 오랜 기간 보호한 동물(2)

hminor 2023. 7. 21. 09:25
SELECT T2.ANIMAL_ID, T2.NAME
FROM ANIMAL_INS T1 JOIN ANIMAL_OUTS T2
ON T1.ANIMAL_ID = T2.ANIMAL_ID
ORDER BY DATEDIFF(T2.DATETIME+1, T1.DATETIME) DESC
LIMIT 2