Q:

Order by min of two dates with nulls first for one column, ignore nulls for another

I want to order my data by the minimum date of two columns, with equal precedence. If Date1 has nulls, I want them to appear first. If Date2 has nulls, I just want to go by Date1. If both dates are null, it should appear at the top.
It 'should' never happen that Date1 is null and Date2 is not.
For example:

Date1      Date2
1/1/2012   1/1/2000
null       null
1/1/2009   1/1/2015
1/1/2013   null
1/1/2003   1/1/2003

Should end up as:

Date1      Date2
null       null
1/1/2012   1/1/2000
1/1/2003   1/1/2003
1/1/2009   1/1/2015
1/1/2013   null

Is this possible?

A:

LEAST and COALESCE should give you what you're after:
with sample_data as (select to_date('01/01/2012', 'dd/mm/yyyy') date1, to_date('01/01/2000', 'dd/mm/yyyy') date2 from dual union all
                     select null date1, null date2 from dual union all
                     select to_date('01/01/2009', 'dd/mm/yyyy') date1, to_date('01/01/2015', 'dd/mm/yyyy') date2 from dual union all
                     select to_date('01/01/2013', 'dd/mm/yyyy') date1, null date2 from dual union all
                     select to_date('01/01/2003', 'dd/mm/yyyy') date1, to_date('01/01/2003', 'dd/mm/yyyy') date2 from dual)
select date1,
       date2
from   sample_data
order by least(date1, coalesce(date2, date1)) nulls first;

DATE1      DATE2     
---------- ----------

01/01/2012 01/01/2000
01/01/2003 01/01/2003
01/01/2009 01/01/2015
01/01/2013           

