SELECT * FROM BOOK
SELECT BOOK_ID
, TO_CHAR (PUBLISHED_DATE, 'YYYY-MM-DD')
FROM BOOK
SELECT BOOK_ID
, TO_CHAR (PUBLISHED_DATE, 'YYYY-MM-DD')
FROM BOOK
WHERE PUBLISHED_DATE
BETWEEN TO_DATE('2021-01-01', 'YYYY-MM-DD')
AND TO_DATE('2021-12-31', 'YYYY-MM-DD')
SELECT BOOK_ID
, TO_CHAR (PUBLISHED_DATE, 'YYYY-MM-DD')
FROM BOOK
WHERE PUBLISHED_DATE
BETWEEN TO_DATE('2021-01-01', 'YYYY-MM-DD')
AND TO_DATE('2021-12-31', 'YYYY-MM-DD')
AND CATEGORY = '인문'
SELECT BOOK_ID
, TO_CHAR (PUBLISHED_DATE, 'YYYY-MM-DD')
FROM BOOK
WHERE PUBLISHED_DATE
BETWEEN TO_DATE('2021-01-01', 'YYYY-MM-DD')
AND TO_DATE('2021-12-31', 'YYYY-MM-DD')
AND CATEGORY = '인문'
ORDER BY PUBLISHED_DATE ASC
XXXX-XX-XX 일자부터 YYYY-YY-YY 일자 까지의 조회
BETWEEN a AND bWHERE 컬럼명 BETWEEN TO_DATE('XXXX-XX-XX', 'YYYY-MM-DD') AND TO_DATE('YYYY-YY-YY', 'YYYY-MM-DD')
Example 1. 1990년도 출생일자를 구하라 [컬럼명 : birth]
WHERE birth BETWEEN TO_DATE('1990-01-01', 'YYYY-MM-DD') AND TO_DATE('1990-12-31', 'YYYY-MM-DD')
Example 2. 1993년 05월생을 출력하라 [컬럼명 : birth]
WHERE birth BETWEEN TO_DATE('1993-05-01', 'YYYY-MM-DD') AND TO_DATE('1993-05-31', 'YYYY-MM-DD')
SELECT * FROM ANIMAL_INS
SELECT NAME
FROM ANIMAL_INS
SELECT NAME
FROM ( SELECT * FROM ANIMAL_INS ORDER BY DATETIME ASC )
SELECT NAME
FROM ( SELECT * FROM ANIMAL_INS ORDER BY DATETIME ASC )
WHERE ROWNUM <= 1
Oracle N개의 데이터 출력
(1) 우선, 데이터 정렬 => SubQuery 사용SELECT empNo , eName , sal FROM ( SELECT empNo , eName , sal FROM emp ORDER BY sal DESC )
(2) 원하는 개수만큼 데이터를 추출 => ROWNUM
SELECT empNo , eName , sal FROM ( SELECT empNo , eName , sal FROM emp ORDER BY sal DESC ) WHERE ROWNUM <= 3
SELECT * FROM USER_INFO
SELECT *
FROM (
SELECT AGE ** AGE 출력을 요함으로 인하여 해당 컬럼 기재
,JOINED
FROM USER_INFO
WHERE JOINED BETWEEN TO_DATE ('2021-01-01', 'YYYY-MM-DD')
AND TO_DATE ('2021-12-31', 'YYYY-MM-DD') )
SELECT *
FROM (
SELECT AGE
, JOINED
FROM USER_INFO
WHERE JOINED BETWEEN TO_DATE ('2021-01-01', 'YYYY-MM-DD')
AND TO_DATE ('2021-12-31', 'YYYY-MM-DD') )
WHERE AGE BETWEEN 20 AND 29