jknj72
asked on
Oracle syntax
I have a query that has 2 dates(start and end date) and if it does not have a value, then its considered a blank, and I want to sort by another date(create date) but if the date has a value I want it sorted by start date. In other words I want the blanks to use create date and if it has a value sort by the start date but I want them all in one sortable field
So maybe we can include an aliased field that has the logic above and I can sort a column but it would have to be a mixture of the 2 fields so if I have 3 records2 with start dates and one blank that has a create date in between the 2 start dates I want them coming back with the blank as the middle date from the sort....
Hope this makes sense.
So maybe we can include an aliased field that has the logic above and I can sort a column but it would have to be a mixture of the 2 fields so if I have 3 records2 with start dates and one blank that has a create date in between the 2 start dates I want them coming back with the blank as the middle date from the sort....
Hope this makes sense.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that should do it. Thanks for your help
ASKER
thanks
isn't a split in order? the accepted post simply restates the same expression originally posted
FWIW, could also have used coalesce(start_date, create_date) sorted_date.
ASKER
thanks
ASKER
logic
if start_date = '' then
create_date
else
start_date
end if as 'SORTED DATE'
What would be the syntax for this?