select 거래일시, 체결건수, 체결수량, 거래대금
from 종목거래
where 종목코드 = 'KR123456'
order by 거래일시
select * from(
select 거래일시, 체결건수, 체결수량, 거래대금
from 종목거래
where 종목코드 = 'KR123456'
and 거래일시 >= '20180304'
order by 거래일시
)
where rownum <= 10
select
from (
select rownum no, a.
from
(
/ SQL Body*/
) a
where rownum <= (:page10)
)
where no >= (:page-1) * 10 + 1
select
from (
select rownum no, a.
from (
select 거래일시, 체결건수, 체결수량, 거래대금
from 종목거래
where 종목코드='KR123456'
and 거래일시 >= '20180304'
order by 거래일시
)a
)
where no between (:page-1)10 + 1 and (:page 10)
SELECT MAX(SAL) FROM EMP WHERE DEPTNO = 30 AND MGR = 7698;
-[DEPTNO + SAL] 인덱스일때 Top N 쿼리 수행시 COUNT(STOPKEY) 수행
SELECT *
FROM (
SELECT SAL
FROM EMP
WHERE DEPTNO=30
AND MGR = 7698
ORDER BY SAL DESC
)
WHERE ROWNUM <= 1;
MAX(변경순번) KEEP (DENSE_RANK LAST ORDER BY 변경일자, 변경순번) 변경순번
, MAX(상태코드) KEEP (DENSE_RANK LAST ORDER BY 변경일자, 변경순번) 상태코드
select region, agv(age), count(*)
from customer
group by region
select lpad(상품번호, 30) || lpad(상품명, 30) || lpad(고객ID, 10)
|| lpad(고객명, 20) || to_char(주문일시, 'yyyymmdd hh24:mi:ss')
from 주문상품
where 주문일시 between :start and :end
order by 상품번호
select lpad(상품번호, 30) || lpad(상품명, 30) || lpad(고객ID, 10)
|| lpad(고객명, 20) || to_char(주문일시, 'yyyymmdd hh24:mi:ss')
from (
select 상품번호, 상품명, 고객ID, 고객명, 주문일시
from 주문상품
where 주문일시 between :start and :end
order by 상품번호
)