DB2

DB2에서의 부분범위 처리

시반 2006. 6. 1. 11:18

1. fetch사용 :(처음부터 몇 개까지만 가져올 경우)

 select * from zoam01 fetch first 5 rows only


2. rownumber()의 사용 (전체범위 중 일부만을 가져오고자 할때)

select   empno, lastname, yyt    from 
    (select 
         empno, lastname, firstname,
         rownumber() over (order by empno) as yyt
       from 
    employee)as t
   where yyt between 20 and 30


* order by 구문이 있는 경우 over()안에 넣어야  order by 처리가 된 전체범위 중 일부만을 가져옵니다

   전 over()만 했더니 전체 범위일때랑 부분범위처리일때랑 가져온 값이 틀려서 *^^*