Home » RDBMS Server » Server Utilities » select second 25 records from a table
select second 25 records from a table [message #73891] Thu, 29 July 2004 21:30 Go to next message
M.A.Raj
Messages: 2
Registered: July 2004
Junior Member
Can anyone send me a query to select the second 25 records sorted based on any column from a table using rownum or any other function
Thank you,

M.A.Raj
Re: select second 25 records from a table [message #73898 is a reply to message #73891] Sun, 01 August 2004 11:02 Go to previous messageGo to next message
ilver
Messages: 50
Registered: January 2004
Member
If "the second 25 records" means record number 26 - 51
of some table.
I think you need to take advantages of some PL/SQL code.
I.e. declare a cursor and loop using a counter.

Remember rownum is a physical identifier. It's fast but hasen't anything to do whith the update history.

/ilver
Re: select second 25 records from a table [message #73935 is a reply to message #73898] Thu, 05 August 2004 01:05 Go to previous message
Andy McGhie
Messages: 7
Registered: July 2004
Junior Member
Ilver,

You could try:
SELECT *
FROM   ( SELECT rownum AS order
       , *
         FROM   tablename
         ORDER BY rownum )
WHERE  order > 25
AND    order <= 50

But this would be a highly inefficient way to do it as you'd effectively be selecting the entire record set in an inline view and then selecting a potentially very small subset out of this.

Andy
Previous Topic: Importing Database problem
Next Topic: Import data only
Goto Forum:
  


Current Time: Wed Jul 03 17:00:50 CDT 2024