Home » RDBMS Server » Server Administration » help required in a sql query (URGENT)
help required in a sql query (URGENT) [message #372432] Tue, 13 February 2001 09:09 Go to next message
sunil menon
Messages: 3
Registered: February 2001
Junior Member
I need to fetch a set of 10 records sequentially based on ROWID from a table which has more than 1000 records.
eg:
TABLE is UW_WORKSHEET and fields to be retrieved are
POLICY_NUMBER, AGE, DECISION_DATETIME
Re: help required in a sql query (URGENT) [message #372434 is a reply to message #372432] Tue, 13 February 2001 12:05 Go to previous messageGo to next message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
you might try something like???

select POLICY_NUMBER, AGE, DECISION_DATETIME
from
(select rowidtochar(rowid), POLICY_NUMBER, AGE, DECISION_DATETIME
from UW_WORKSHEET
group by rowidtochar(rowid))
where rownum <= 10;

or

select POLICY_NUMBER, AGE, DECISION_DATETIME
from
(select rowid, POLICY_NUMBER, AGE, DECISION_DATETIME
from UW_WORKSHEET
group by rowid)
where rownum <= 10;

the group by sorts the subquery.
Re: help required in a sql query (URGENT) [message #372441 is a reply to message #372434] Tue, 13 February 2001 16:59 Go to previous messageGo to next message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
The use of an order by in the inline view is actually better, as you can sort ASC or DESC as opposed to the old GROUP BY trick.

select POLICY_NUMBER, AGE, DECISION_DATETIME
from
(select rowid, POLICY_NUMBER, AGE, DECISION_DATETIME
from UW_WORKSHEET
order by rowid)
where rownum <= 10;
Re: help required in a sql query (URGENT) [message #372448 is a reply to message #372434] Wed, 14 February 2001 03:19 Go to previous message
sunil menon
Messages: 3
Registered: February 2001
Junior Member
thanks for the reply andrew..this will give me first 10.

But my requirement is to get sequential chunks of records
eg:
This is a webpage in which I have to show 30 records.When the page is initially loaded it will load 1 to 10 records. When the user clicks the NEXT button, page should display record number
10 to 20 records. ...so on 20-30 and 30-40

It will be great if u could suggest something for this

thanks
Previous Topic: Disabling primary Key
Next Topic: Cursor
Goto Forum:
  


Current Time: Wed May 15 15:32:22 CDT 2024