If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > fetching the rows from table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-30-09, 10:59
pradeesh87 pradeesh87 is offline
Registered User
 
Join Date: Jun 2009
Posts: 4
Unhappy fetching the rows from table

Hi,

I have a db2 table with 600 rows.

I need to write 3 sql queries

the first query should retrieve first 200 rows in that table
next query should retrive the next 200 rows from that table
next query should retrive the next 200 rows from that table

i knw how to write the sql query for this req in oracle db but I dnt have any idea about DB2.. can anyone help me on this?
Reply With Quote
  #2 (permalink)  
Old 06-30-09, 11:21
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
with t1 as (rownum, col1, col2,...) as (
select row_number() over (order by col1),x.*
from mytable as x
) select * from t1 where rownum between 1 and 200

Change the between clause for the other 2 queries.

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On