| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
|||
rownum in 9iHi friends
when ever i try to use rownum function other than < or <= it gives no row selected like select * from emp where rownum=2; select * from emp where rownum>=3; no row selected while emp hav 14 rows.. plz reply |
|
|||
|
hi ashish,
i am sending u a link Filtering (WHERE) and Sorting Data (ORDER BY) in Oracle 9i > Filtering with the WHERE Clause there's a heading TOP - N QUERIES hope this will help u.... shashi jain Last edited by shashi jain : 09-23-2007 at 05:45 PM. |
|
|||
|
when u execute the SQL statement it always execute with 1 as rownum.
for ex : select * from emp where rownum>=3; this statement, when executes first time rownum is 1.next time rownum is 2...soon. Sequence of Steps for Executing above SQL Statement: select * from emp where 1>=3; - True select * from emp where 2>=3; - True select * from emp where 3>=3; - True select * from emp where 4>=3; - False the query executes 3 times and 3 rows will dispaly. but when run following statement , select * from emp where rownum=2; Sequence of Steps for Executing above SQL Statement: select * from emp where 1=2;which is false. hence it returns 0 rows. So Note that while Executing SQL Statement with Rownum it Always start from 1(i.e) first row.. |
|
|||
|
frend
u cant use " =" operator with rownum so u acn use either > or < till it wll be fine |