What about nulls?
Jimbo, November 22, 2005 - 4:36 am UTC
The answer depends on whether you need to handle NULLs. The MIN of a set containing a NULL will be NULL only if all values are NULL. The LEAST of a pair containing a NULL will be NULL if either or both of the pair are NULL.
select emp_id, emp_name,
Least(Nvl2(date1,Nvl(date1,To_Date('01014000','DDMMYYYY')),date2),
Nvl2(date2,Nvl(date2,To_Date('01014000','DDMMYYYY')),date1))
(I'm assuming the system will be replaced before any employee records encompass the year 4000)
whoops!
Jimbo, November 22, 2005 - 4:39 am UTC
that would be
SELECT Least(Nvl2(date1,date1,date2),
Nvl2(date2,date2,date1))