Ordering photos by item_date OR item_year

Philip Greenspun's Homepage : Philip Greenspun's Homepage Discussion Forums : 6916 : One Thread
Notify me of new responses
Is there a magic way to combine the results of a select of two columns
into one column so that I may "ORDER BY?"  of course, one or the other
would be null for any given row.

with a view, perhaps?

select to_date(item_year, 'YYYY') as the_date, item_date
from family_photos
where ...

-- Bobby Prill, March 8, 2000


I don't think it required any magic. I did it by creating a procedure but a few hours later realized that it can also be done with a statement like

select nvl(first_column,second_column) as what_ever from table_name order by what_ever;

I think column_one and column_two have to be of the same datatype though otherwise it won't work. In that case you would have to create a procedure.

Good luck !!

-- Koroush Iranpour-Tehrani, March 8, 2000