Nested decode

I am trying to get this result from oracle 9i:

Job               Dept10               Dept20          Dept30           Total
ANALYST                                8000                                  6000
CLERK             1300                 1900                 950           4150
MANAGER        2450                 2975                2850          8275
PRESIDENT      5000                                                         5000
 
I saw an example using nested decodes that looked someting like this, but I can't seem to put it together. Thanks in advance for looking.                                                        
georgethebastardAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
DanielztConnect With a Mentor Commented:
if it works for you, please accept my solution as your answer. and the other people do not need to work on this again. thanks.
0
 
DanielztCommented:
try this:

select job, sum(decode(dept,10,sal,0)) as dept10,
 sum(decode(dept,20,sal,0)) as dept20,
sum(decode(dept,30,sal,0)) as dept 30
from emp
group by job
0
 
georgethebastardAuthor Commented:
Yes!
Thank You
I appreciate this very much.
0
All Courses

From novice to tech pro — start learning today.