Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Matrix type of Query

ramarunApr 20 2011 — edited Apr 21 2011
Hi All,

I have the following query and its give a desired output like a matrix.
SELECT  DEPTNO,
 DECODE(DEPTNO,10,COUNT(*))TEN,
 DECODE(DEPTNO,20,COUNT(*))TWO,
 DECODE(DEPTNO,30,COUNT(*))THREE,
 DECODE(DEPTNO,40,COUNT(*))FOUR
FROM EMP
GROUP BY DEPTNO
I want to have a output like the below format, can the pro's help me with the right query or give a approach for the same.
Deptno    10         20       30      40
Values    100       200     300     400
Thanks in advance
This post has been answered by Solomon Yakobson on Apr 20 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 19 2011
Added on Apr 20 2011
8 comments
426 views