View Single Post

   
  #2 (permalink)  
Old 02-26-2008, 06:05 PM
Mark A
 
Posts: n/a
Default Re: Row Number or subset of select.

"Alex Kizub" <akizub@yahoo.com> wrote in message
news:402AAF8B.34DCD873@yahoo.com...
> Is it possible to retrive only part of query result?
>
> Like Oracle has, for example, rownum and it can be part of conditions:
> select * from table where rownum < 10
>
> Problem is that table is huge (billions records) and when user is
> subborn enough and reach page #100,000 then application has to read and
> skip these 100,000,000 records to obtaine next page.
>
> Please, don't tell me that table can be changed, sorted and so on.
> I'm talking about one particular request in one time. But I need rows
> from N to N+10 from table with M rows.
>
> Is it possible in DB2 (Version 7)?
> Alex Kizub.
>

If you just need the first 10 rows, you can use the following on the end of
your select
FETCH FIRST 10 ROWS ONLY
See the SQL reference.

If you want some other range of rows (in the middle of the answer set), then
look at the OLAP functions with row_number () over


Reply With Quote