• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to select resultset in range?

 
Conie Ooi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm in a situation which I need to select rows from table in a range, let's say from record 3 to record 5. Is there any command in DB2 can do the job for me?
Thanks a lot and waiting for your reply..
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain a little more what you're trying to do? It seems a little odd that you need to select rows 3-5 in a table like that. Isn't there a specific field value(s) you can add to your WHERE clause to identify the records you need? Sorry, maybe I'm just misunderstanding you :roll:
 
Conie Ooi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've found the solution to my problem already.. thanks a lot..
 
timothy passcal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this thread is really old....
Does anyone have a solution on how to do this in DB2?
Select * from X where database returns only rows 21 through 30.
Thanks.
 
Dana Hanna
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't fully answer this, but I can send you in the right direction:
adding
"FETCH FIRST 40 ROWS ONLY"
to your SQL statement gets the first 40, but I don't think you can tell it to drop the first X amount.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dbForums has a good thread on this. You can do it with a nested query, but it will be very inefficient.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic