View Single Post
Old 02-07-2005, 05:43 PM   #2 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 287
technobard is on a distinguished road
You're talking about running SQL against a flat file? The only database I know of that can handle that is Oracle using "external" to make the outside file appear to be an internal table. Is that what you're using? If so, you can probably use a decode on the second date.

Something like:
Code:
select .... from external_table 
order by decode(second_date, '0000-00-00', first_date, 
second_date)
Decode is basically an "if" statement, so if you're not using Oracle, (and decode is not available) you can use whatever the language allows for conditionals. This may or may not be supported in the order by clause for other DBMSs, but Oracle does support it.

The decode above translates as:
if (second_date == '0000-00-00') {
return first_date;
} else {
return second_date;
}
__________________
It takes 2 points to draw a straight line, but at least 3 points to draw a conclusion.
technobard is offline   Reply With Quote