Solved

Nested decode

Posted on 2003-10-23
3
1,166 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
  • 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 130 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
levels for reporting 5 51
Oracle Syntax 8 42
How to return an OUT parameter from and ORACLE 3 35
Clone Oracle 12c Database 5 27
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
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 syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now