Home » SQL & PL/SQL » SQL & PL/SQL » rownum grater than 1 (merged)
rownum grater than 1 (merged) [message #388824] Thu, 26 February 2009 05:36 Go to next message
ramesh55.sse
Messages: 262
Registered: December 2008
Location: Hyderabad
Senior Member
Why we can't use Rownum with grater than?

select *from emp where rownum>=5;

why it's returning no rows
Rownum with 1 [message #388827 is a reply to message #388824] Thu, 26 February 2009 05:46 Go to previous messageGo to next message
ramesh55.sse
Messages: 262
Registered: December 2008
Location: Hyderabad
Senior Member
select * from emp where rownum=1;

why rownum works only with 1,why it's not working with other than 1 ?
Re: Rownum with 1 [message #388828 is a reply to message #388827] Thu, 26 February 2009 05:58 Go to previous messageGo to next message
aviva4500
Messages: 122
Registered: July 2008
Location: bangalore
Senior Member
@ramesh55.sse,

1. It will work if you issue > or <....

2. http://blog.lishman.com/2008/03/rownum.html

3. Check the above link which gives you some idea on RowNum.



Regards,
Hammer

[Updated on: Thu, 26 February 2009 06:02]

Report message to a moderator

Re: rownum grater than [message #388834 is a reply to message #388824] Thu, 26 February 2009 06:11 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Why not reading the documentation?
Why not searching for this FAQ?

Regards
Michel
Re: Rownum with 1 [message #388843 is a reply to message #388827] Thu, 26 February 2009 06:19 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Rownum is assigned to a row as it is fetched from the database.

So,if you're looking for rownum >5, Oracle will get the first row, see the it's got rownum 1, and discard it.
It will then get the next row, see that it hasn't got any rows yet, give this onw a rownum of 1, check to see if it'srownum is > 5, and discard the row.
Repeat until out of rows.
Previous Topic: UNIX-Oracle Error
Next Topic: java.sql.SQLException: Protocol violation (merged)
Goto Forum:
  


Current Time: Sat Feb 08 07:52:46 CST 2025