-- https://school.programmers.co.kr/learn/courses/30/lessons/59411SELECT i.animal_id, i.name
from animal_ins i
join animal_outs o
on i.animal_id =o.animal_id
orderby o.datetime-i.datetimedesclimit2
빼기 대신 datediff 메서드를 사용해도 됨 DATEDIFF(O.DATETIME,I.DATETIME)