?
Solved

Nested decode

Posted on 2003-10-23
3
Medium Priority
?
1,175 Views
Last Modified: 2013-12-11
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
Comment
Question by:georgethebastard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Expert Comment

by:Danielzt
ID: 9612203
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
 

Author Comment

by:georgethebastard
ID: 9613014
Yes!
Thank You
I appreciate this very much.
0
 
LVL 8

Accepted Solution

by:
Danielzt earned 520 total points
ID: 9613916
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question