Link to home
Start Free TrialLog in
Avatar of georgethebastard
georgethebastard

asked on

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.                                                        
Avatar of Danielzt
Danielzt

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

ASKER

Yes!
Thank You
I appreciate this very much.
ASKER CERTIFIED SOLUTION
Avatar of Danielzt
Danielzt

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