Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-12-05 : 07:33:41
|
Jhankar writes "Hi, I am facing a peculiar problem. I have to fetch the last 16 records from a db2 table. I can fetch the last 16 records in descending order. But, my requirement is these records in Ascending order.Currently, I have executed this code using two cursors, but this way the nbr of i/o are doubled, and it overloads my systemMy first cursor (CUR 1) reads the table in descending order till i get the 16th key from bottom.Then another cursor (CUR 2) fetches the 16 records in forward manner. So, actually I am using twice the nbr of queries.When I try using the first fetch (CUR 1) to fetch the last 16 records from CUR 2 in ASC order the result set returns the top 16 records from my table. And when I try using the first key of CUR 1 to fetch 16 records from the CUR 2 in DESC order I do get my set but I need to now sort this in ASC order to use it.Is there a way to order this set in ASC w/o doing the double series of fetches?" |
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
|
|