Home » SQL & PL/SQL » SQL & PL/SQL » Last Rows
Last Rows [message #10832] Thu, 19 February 2004 02:13 Go to next message
Nigel Garwood
Messages: 3
Registered: February 2004
Junior Member
Hi

How do I return the last 10 rows of my table ?

Nigel
Re: Last Rows [message #10834 is a reply to message #10832] Thu, 19 February 2004 04:38 Go to previous messageGo to next message
Jitendra Agrawal
Messages: 71
Registered: December 2003
Member
Hi,

See the following link !
http://asktom.oracle.com/pls/ask/f?p=4950:8:12407344825521320121::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:127412348064,

select *
from ( select a.*, rownum rnum
from ( YOUR_QUERY_GOES_HERE -- including the order by ) a
where rownum <= MAX_ROWS )
where rnum >= MIN_ROWS
/

Basically you need to get the min_rows and max_rows by doing a count first.

Regards,
Jitendra Agrawal

http://www.telemune.com/
Re: Last Rows [message #10863 is a reply to message #10834] Fri, 20 February 2004 19:09 Go to previous messageGo to next message
chandi priya
Messages: 1
Registered: February 2004
Junior Member
select * from
(select rownum a,column_name from table_name)
where a>(select max(rownum)-10 from table_name)
Re: Last Rows [message #10872 is a reply to message #10834] Sat, 21 February 2004 05:45 Go to previous message
venkey
Messages: 2
Registered: February 2004
Junior Member
the best option is to write cursor using pl/sql and have an counter or execute this query select * from
where rownum>=10
Previous Topic: Parsing comma separated String
Next Topic: Help to write SQL scripts please.
Goto Forum:
  


Current Time: Fri Apr 26 11:33:04 CDT 2024