-
decode in order by
Hi,
I want to use decode in order by in following way -
select * from dept
order by decode(.......)
if deptno=1 then order by deptname desc, deptcity asc
if deptno=2 then order by deptno desc, deptname asc, deptcity desc
else
order by deptno desc, deptcity asc.
Can anyone please help me?
Thank you in advance.
-
I think decode() is not the tool to hammer that specific nail.
I would go with
ORDER BY
CASE
WHEN...
WHEN...
ELSE...
END
-
decode in order by
Can u please give an example ?
-
Look at the first result when you Google: Oracle, order by case statement ...
http://www.compoundtheory.com/?action=displayPost&ID=39
... isn't it a beauty?