✅ 코드
SELECT I.ANIMAL_ID
, I.NAME
FROM ANIMAL_INS AS I
INNER JOIN ANIMAL_OUTS AS O ON I.ANIMAL_ID = O.ANIMAL_ID
WHERE I.DATETIME > O.DATETIME
ORDER BY I.DATETIME;
INNER JOIN을 수행한 이유는 보호 시작일과 입양일 정보를 모두 갖고 있는 동물들이 대상이기 때문입니다.
'알고리즘' 카테고리의 다른 글
[SQL]프로그래머스 Lv.4 보호소에서 중성화한 동물 (0) | 2023.08.07 |
---|---|
[SQL]프로그래머스 Lv.3 오랜 기간 보호한 동물(2) (0) | 2023.08.07 |
[SQL]프로그래머스 Lv.3 오랜 기간 보호한 동물(1) (0) | 2023.08.06 |
[SQL]프로그래머스 Lv.2 카테고리별 상품 개수 구하기 (0) | 2023.08.05 |
[SQL]프로그래머스 Lv.2 중성화 여부 파악하기 (0) | 2023.08.05 |