I have a file that has two date fields in it. The first date is always there but the second date field may or may not have a value, like this:
Code:
A 2005-01-29 2004-10-15
B 2004-09-19 0000-00-00
C 2004-12-31 0000-00-00
D 2005-01-02 2004-11-11
I want to select the data ORDER BY the first date UNLESS the second date is present, then I want it to use that date for that row instead. So after sorting, the order above would be BADC. How do I code the ORDER BY for this kind of sort?