Home » SQL & PL/SQL » SQL & PL/SQL » ABOUT ROWNUM
ABOUT ROWNUM [message #210767] Fri, 22 December 2006 04:40 Go to next message
sandeepshahare
Messages: 20
Registered: December 2006
Location: pune
Junior Member
When i write select * from emp
where rownum<10; then
it show first 9 records from the emp;
but i want last 9 record then how to modify the above query?
Re: ABOUT ROWNUM [message #210776 is a reply to message #210767] Fri, 22 December 2006 05:02 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Check this
By
Vamsi
Re: ABOUT ROWNUM [message #210791 is a reply to message #210776] Fri, 22 December 2006 06:58 Go to previous message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Just a quick note: to get the Top N:
SELECT *
FROM ( SELECT columns
       FROM   yourtable
       ORDER BY some_columns
     )
WHERE rownum <= N


to get the bottom N:
SELECT *
FROM ( SELECT columns
       FROM   yourtable
       ORDER BY some_columns_inverted --(ASC becomes DESC and vice versa)
     )
WHERE rownum <= N


A search along the board will reveal more.

MHE
Previous Topic: DELETE SUCCESFUL BUT DOESNT GET IMPLEMENTED IN TABLE
Next Topic: ORA-08002: sequence NAME.CURRVAL is not yet defined in this session
Goto Forum:
  


Current Time: Fri Dec 09 02:26:49 CST 2016

Total time taken to generate the page: 0.14115 seconds