SQL - Getting Most Recent Date From Multiple Columns

Posted by ScottSEA on Stack Overflow See other posts from Stack Overflow or by ScottSEA
Published on 2010-06-02T15:49:33Z Indexed on 2010/06/02 15:54 UTC
Read the original article Hit count: 154

Filed under:

Assume a rowset containing the following

EntryID    Name      DateModified   DateDeleted
-----------------------------------------------  
1          Name1     1/2/2003       NULL
2          Name1     1/3/2005       1/5/2008
3          Name1     1/3/2006       NULL
4          Name1     NULL           NULL  
5          Name1     3/5/2008       NULL

I need to return the largest (i.e. most recent) non-null date from DateModified and DateDeleted, in this case 3/5/2008.

© Stack Overflow or respective owner

Related posts about sql