본문 바로가기
프로그래머스/[프로그래머스 - ORACLE] Lv.1

[프로그래머스 - ORACLE] 있었는데요 없었습니다

by 코딩하는 흰둥이 2023. 3. 21.


CREATE 문
CREATE TABLE ANIMAL_INS (
ANIMAL_ID			VARCHAR2(100)		NOT NULL PRIMARY KEY,
ANIMAL_TYPE			VARCHAR2(100)		NOT NULL,
DATETIME			TIMESTAMP		NOT NULL,
INTAKE_CONDITION		VARCHAR2(100)		NOT NULL,
NAME				VARCHAR2(100)		NULL,
SEX_UPON_INTAKE			VARCHAR2(100)		NOT NULL
)





CREATE TABLE ANIMAL_OUTS  (
ANIMAL_ID			VARCHAR2(100)			NOT NULL ,
ANIMAL_TYPE			VARCHAR2(100)			NOT NULL,
DATETIME			TIMESTAMP			NOT NULL,
NAME				VARCHAR2(100)			NULL,
SEX_UPON_OUTCOME		VARCHAR2(100)			NOT NULL,
CONSTRAINT FK_ANIMAL_ID FOREIGN KEY(ANIMAL_ID) REFERENCES ANIMAL_INS(ANIMAL_ID)
)

 


  • 내 풀이
SELECT
    I.ANIMAL_ID,
    I.NAME
FROM ANIMAL_INS I INNER JOIN ANIMAL_OUTS O
ON I.ANIMAL_ID = O.ANIMAL_ID
AND I.DATETIME > O.DATETIME 
ORDER BY I.DATETIME ASC;

댓글