top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How does one code a matrix report in SQL using SUM & DECODE function?

+1 vote
62 views
How does one code a matrix report in SQL using SUM & DECODE function?
posted May 29, 2015 by Kunal Kapoor

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes
   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;

    JOB           DEPT10     DEPT20     DEPT30     DEPT40
    --------- ---------- ---------- ---------- ----------
    ANALYST                    6000
    CLERK           1300       1900        950
    MANAGER         2450       2975       2850
    PRESIDENT       5000
    SALESMAN                              5600
answer Jun 1, 2015 by Arun Gowda
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...