Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Comparing date rows with GREATEST

715920Apr 14 2011 — edited Apr 15 2011
Dear all,
why doesn't the last statement query any values?
suppose:
 SQL> select * from test;

TEMP_DATE
---------
14-APR-11
15-APR-11
16-APR-11

SQL> select months_between(to_date((select temp_date from test where rownum=1)),to_date((select temp_date from test where rownum=2)))test from test;

      TEST
----------




 
I try to get the greatest date from temp_date column of test table but instead I got null values dump. What went wrong?
Is there any easier way to compare those values using GREATEST (I can do it easily with MAX function though)?

best regards,
Val

Edited by: Valerie Debonair on Apr 14, 2011 8:48 PM
This post has been answered by Frank Kulash on Apr 15 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2011
Added on Apr 14 2011
4 comments
453 views