View previous topic :: View next topic
|
Author |
Message |
jeyaraj
New User
Joined: 14 Nov 2005 Posts: 5
|
|
|
|
hi,
please let me know how to fetch records in between. ie from 11th record to 15 th record in a table without using cursor. |
|
Back to top |
|
|
rajandhla
Active User
Joined: 18 Oct 2005 Posts: 182 Location: Luton UK
|
|
|
|
If you want to retreive/fetch using single query then you should use cursor concept.............
regards
jai |
|
Back to top |
|
|
parikshit123
Active User
Joined: 01 Jul 2005 Posts: 269 Location: India
|
|
|
|
Hi,
I think, if your select query returns more than one row, then you must use a cursor.
Let me know if I am not correct here.
Thanks,
Parikshit. |
|
Back to top |
|
|
jeyaraj
New User
Joined: 14 Nov 2005 Posts: 5
|
|
|
|
hi,
i want a query to display 10th record to 15th record. is there any possibility like display records using its record counter in DB2. |
|
Back to top |
|
|
mahsug
New User
Joined: 01 Jul 2003 Posts: 15 Location: Phoenix , AZ
|
|
|
|
Hi ,
You can do it using key value , say I have a field called Recseq (Record Sequence )
select * from tablea where keyfield in (select keyfield from tablea where keyfield>10) fetch first 5 rows only
or, if you have any sequence / identity or Rowid column , then you can try querying with that field
Let me know , if more questions
Thanks
Mahesh |
|
Back to top |
|
|
Jerry
New User
Joined: 16 Sep 2005 Posts: 42
|
|
|
|
Hi Jeyaraj,
Hope this helps:
Select * from tbname fetch first 10 rows only where keyfield not in (select * from tbname fetch 9 rows only);
Select * from tbname fetch first 15 rows only where keyfield not in (select * from tbname fetch 14 rows only);
Correct me if I am wrong.
Regards,
Jerry. |
|
Back to top |
|
|
sri.mainframes
New User
Joined: 16 Feb 2006 Posts: 29 Location: MUMBAI
|
|
|
|
hi Jerry ,
your query retrieves 10th and 15 th row only but not 10 to 15 rows
hi jeyaraj try this one
Select * from tbname fetch first 15 rows only where keyfield not in (select * from tbname fetch 9 rows only);
suggestions welcomed
regards
PRINCE |
|
Back to top |
|
|
umeshkmrsh
New User
Joined: 21 Sep 2005 Posts: 79 Location: India
|
|
|
|
You cant say that a row occurs on possition 10th and 15th until you are browsing data based on some order by clause.
In order to solve your problem look for primary keys of those rows.
and then use :
SELECT * FROM TABLEA WHERE PKEY IN (KEY11,KEY11,KEY12,KEY13,KEY14,KEY15); |
|
Back to top |
|
|
|