-
[level 3] 오랜 기간 보호한 동물(2)SQL/SQL 연습문제 풀이 2022. 1. 19. 12:59반응형
https://programmers.co.kr/learn/courses/30/lessons/59411
MySQL
-- MySQL SELECT B.ANIMAL_ID, B.NAME FROM ANIMAL_INS A JOIN ANIMAL_OUTS B ON A.ANIMAL_ID = B.ANIMAL_ID ORDER BY B.DATETIME - A.DATETIME DESC LIMIT 2
Oracle
SELECT * FROM ( SELECT B.ANIMAL_ID, B.NAME FROM ANIMAL_INS A JOIN ANIMAL_OUTS B ON A.ANIMAL_ID = B.ANIMAL_ID ORDER BY B.DATETIME - A.DATETIME DESC) WHERE ROWNUM<=2
반응형