Solved

Pivotal sql

Posted on 2008-10-15
2
262 Views
Last Modified: 2013-12-07
SELECT  *
  FROM  (SELECT job,
                sum(decode(deptno,10,sal)) DEPT10,
                sum(decode(deptno,20,sal)) DEPT20,
                sum(decode(deptno,30,sal)) DEPT30,
                sum(decode(deptno,40,sal)) DEPT40
           FROM scott.emp
       GROUP BY job)
ORDER BY 1;

Is there a way to make deptno a select from scott.dept table? not hardcode it.  Thanks
0
Comment
Question by:Zopilote
2 Comments
 
LVL 27

Accepted Solution

by:
sujith80 earned 50 total points
ID: 22728907
Oracle 11i - use PIVOT syntax
Else - no
0
 
LVL 5

Author Closing Comment

by:Zopilote
ID: 31506470
Thank you sujith80!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update foreign key reference after insert 9 47
SQL join help to a thrid table 51 76
SQL Union 20 44
How do I call MySQL Stored Procedure from oracle using HS link ? 5 25
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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

911 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

21 Experts available now in Live!

Get 1:1 Help Now