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!

Taking the greatest date from 3 Date Columns

spalato76Oct 5 2011 — edited Oct 5 2011
Hi All,

I have 3 Date/Time columns in my table:

DateTime_1,
DateTime_2,
DateTime_3

I'm trying to select the maximum or greatest date from any of these 3 columns. Any of the columns can be null. I've tried using a combination of the coalesce and greatest functions to get the maximum date value. When I use a coalesce on the 3 columns it works fine but when I nest the coalesce in the greatest function, ie Greatest(Coalesce(...)) it is taking a null value. Should I include an nvl on each column?

Any help would be appreciated.

Thanks,
Ed
This post has been answered by Solomon Yakobson on Oct 5 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 2 2011
Added on Oct 5 2011
6 comments
5,313 views