for the sake of simplicity I have two date fields in a table I'll call date1 and date2.
what is the most elegant way to get the earliest (in time) date of the two that is not null or zero? I could do this:
SELECT
IF(date1 IS NULL, date2, IF(date1 < date2, date1, date2))
but I'd like to know if there's a more elegant way.
In php I could just use MIN(date1, date2, date3, .. ) (other than the fact that date1 or 2 might be NULL) - but MIN() in SQL language means a different thing and doesn't take multiple arguments.
Thanks and happy thanksgiving!