[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1181
  • Last Modified:

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.                                                        
0
georgethebastard
Asked:
georgethebastard
  • 2
1 Solution
 
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
 
DanielztCommented:
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now