In EMP table when I execute the syntax
Select * from emp where ename in('king','Allen','Blair','Tony')
it gives the output in the same sequence of names as stored in table e.g first allen,tony,king and then blair. But I require the output in the same sequence same as in query as king,allen,blair and then tony.
In Oracle I can do it by Decode function but in SQL server there is no DECODE function.
Please help
select ename from emp where ename= CASE
WHEN 'james' THEN '1'
WHEN 'king' THEN '2'
WHEN 'allen' THEN '3'
WHEN 'clark' THEN '4'
END in('1','2','3','4') order by CASE ename
WHEN 'james' THEN '1'
WHEN 'king' THEN '2'
WHEN 'allen' THEN '3'
WHEN 'clark' THEN '4'
END
Bookmarks