Link to home
Start Free TrialLog in
Avatar of searchsanjaysharma
searchsanjaysharma

asked on

How to set order by clause for this query.

create table mstsubs (subjects varchar(200))
insert into mstsubs(subjects) values('aaan')
insert into mstsubs(subjects) values('baan')
insert into mstsubs(subjects) values('caan')

The output should be
select
ALL
aaan
baan
caan
I am using the following query but not working out.

select subjects
from(select 'Select' as subjects union select subjects from mstsubs
union select 'All' as subjects union select subjects from mstsubs)x
order by case
when subjects = 'Select' then 0
when subjects='ALL' THEN 1
END
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

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
Avatar of searchsanjaysharma
searchsanjaysharma

ASKER

tx