Thursday, February 17, 2011

ORDER BY AND ROWNUM ISSUE IN ORACLE

Example :

WRONG ONE :
1. select * from table where rownum <= 2 order by 1 desc
2.select xam from ho_aa where ROWNUM = 1 ORDER BY LOG_TIME DESC
CORRECT ONE :
1. select * from (select * from table order by 1 desc) where rownum <= 2
2.select xam from (select xam from ho_aa ORDER BY LOG_TIME DESC) where ROWNUM = 1

REASON : Rownum is assigned after the row is selected BUT BEFORE ORDER BY

Monday, February 14, 2011

Dress code for feb 14.

Blue - free
Green -waiting
Orange -going to propose
Pink - accepted proposal
Black - rejected proposal
White - all ready booked
Yellow - broke up
Gray - not interested
Red- leave me alone.