I want to select a2.date if it\'s there, but if it\'s NULL I want to select a1.date (a2 is being left-joined). This:
a2.date
NULL
a1.date
a2
Check out the COALESCE function.
Takes a variable number of arguments and returns the first non-null one. It works fine with joins.