bschave2
asked on
How do I word case statement in order by clause with a union?
I need to add a 'all' company type in my result for a drop down list, however the order in which the "all" company is showing is at position 8 or 9 and I want 'all' to show up at position 0 in the result order.
this is what I have s far:
SELECT COM_ID, COM_SHORT_NAME FROM TBLCOMPANY
UNION
SELECT 0 AS COM_ID, 'ALL' AS COM_SHORT_NAME FROM DUAL
ORDER BY CASE 2 WHEN 'ALL' THEN 1 END ASC;
this is what I have s far:
SELECT COM_ID, COM_SHORT_NAME FROM TBLCOMPANY
UNION
SELECT 0 AS COM_ID, 'ALL' AS COM_SHORT_NAME FROM DUAL
ORDER BY CASE 2 WHEN 'ALL' THEN 1 END ASC;
ASKER
I WANT TO SORT BY COM_SHORT_NAME
ASKER
and the com id for all is 0
ASKER
I have a case statement in the order by clause.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
order by 1