Link to home
Start Free TrialLog in
Avatar of bschave2
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;
Avatar of Sean Stuber
Sean Stuber

assuming you have non-zero com_id's in your table and you want 0 to be first...


order by 1
Avatar of bschave2

ASKER

I WANT TO SORT BY COM_SHORT_NAME
and the com id for all is 0
I have a case statement in the order by clause.
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial