select case when (case when date1>date2 then date1 else date2 end )>date3 then (case when date1>date2 then date1 else date2 end) else date3 end from t_date