oracle sql wih rownum <= -


why below query not giving results if remove < sign query.because without < must match results?

query used second max id value:

select min(id)  from(     select distinct id      student      order id desc )  rownum <=2 


student id  1 2 3 4 

rownum has special meaning in oracle. increased every row, optimizer knows increasing continuously , consecutive rows must met rownum condition. if specify rownum = 2 never occur since first row rejected.

you can see nice if explain plan on query. show like:

plan rownum <=:

count stopkey        

plan rownum =:

filter 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -