[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

need some modification in query

Posted on 2014-02-19
3
Medium Priority
?
269 Views
Last Modified: 2014-02-19
Hello Expert,

i am using oracle 11g.

below is my query

 

 SELECT a.year_quater,

 

       NVL(a.region_ls,a.region_wp) AS Region,

       count(DECODE(a.final_disposition,'10',1)) as BRC,

       count(DECODE(a.final_disposition,'20',1)) as RO,

       count(DECODE(a.final_disposition,'40',1)) as WPC,

       count(DECODE(a.final_disposition,'30',1)) as Merged,

       count(DECODE(a.final_disposition,'60',1)) as Dropped

FROM ms_fcr_issue a

group by a.year_quater,NVL(a.region_ls,a.region_wp)

order by Region

my out put is like this

Year_Quarter   Region                         BRC     RO      WPC  MERGED  DROPPED

2013-Q1           EMEA                               1         0           0         0                   0

2013-Q2           NAM,APAC,LATAM         1         0           0         0                   0      

2013-Q3           EMEA                                1         1           0        0                    0

2013-Q4           LATAM                               1         0           1        1                   0

but i need output  like  instead of 2013-Q1  need below only Q1 Q2....

                     2013-Q1      2013- Q2  2013- Q3    2013-Q4      

BRC                            

RO

WPC

MERGED

DROPPED

Regards

Damby
0
Comment
Question by:deve_thomos
[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
3 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 2000 total points
ID: 39870633
Try this:
SQL> l
  1  WITH Ms_Fcr_Issue (Region_Ls, Region_Wp, Final_Disposition, Year_Quarter)
  2       AS (SELECT 'EMEA', '', '20', '2013-Q1' FROM DUAL UNION
  3           SELECT '', 'NAM,APAC,LATAM', '10', '2013-Q2' FROM DUAL UNION
  4           SELECT 'EMEA', '', '10', '2013-Q3' FROM DUAL UNION
  5           SELECT 'EMEA', '', '20', '2013-Q3' FROM DUAL UNION
  6           SELECT '', 'LATAM', '10', '2013-Q4' FROM DUAL UNION
  7           SELECT '', 'LATAM', '40', '2013-Q4' FROM DUAL UNION
  8           SELECT '', 'LATAM', '30', '2013-Q4' FROM DUAL)
  9     , Codes (Cd, Cdesc)
 10       AS (SELECT '10', 'BRC' FROM DUAL UNION
 11           SELECT '20', 'RO' FROM DUAL UNION
 12           SELECT '30', 'MERGED' FROM DUAL UNION
 13           SELECT '40', 'WPC' FROM DUAL UNION
 14           SELECT '60', 'DROPPED' FROM DUAL)
 15  SELECT * FROM (
 16  SELECT K.Cdesc, Year_Quarter
 17    FROM Ms_Fcr_Issue A, Codes K
 18   WHERE K.Cd = A.Final_Disposition(+))
 19*  PIVOT (count(*) for Year_Quarter IN ('2013-Q1','2013-Q2','2013-Q3','2013-Q4'))
SQL> /

CDESC               '2013-Q1'  '2013-Q2'  '2013-Q3'  '2013-Q4'
------------------ ---------- ---------- ---------- ----------
BRC                         0          1          1          1
WPC                         0          0          0          1
RO                          1          0          1          0
MERGED                      0          0          0          1
DROPPED                     0          0          0          0

Open in new window

0
 

Author Closing Comment

by:deve_thomos
ID: 39872502
Thanks a lot
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
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 explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

649 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