Help in Pivot Query- To change the column data to rows data!

Hello Gurus -
I have to change the row to Column -
When i use the query -
select NVL (T2.NAME, ' Grand Total') AS State,count(T2.NAME) as Total
from Defect T1,statedef T2,repoproject T3
WHERE T1.STATE=T2.ID AND T1.repoproject = T3.dbid AND T3.name like '%Compass Juice' GROUP BY ROLLUP (T2.NAME)
Then i have got the following data -
STATE          TOTAL
Analysis     17
Closed          1302
Development     9
Duplicate     24
Failed          2
OnHold          4
Opened          146
QA          1
ReadyForQA     1
Withdrawn      335
Grand Total     1841
But i want the data in following format -
State Analysis     Closed     Development      Duplicate     Failed     OnHold     Opened     QA     ReadyForQA     Withdrawn     GrandTotal
Total 17     1302     9          24          2     4     146     1     1          335          1841
Kindly help me with this. I searched the forum and saw the usage of Max and NVL, Decode but i am unable to understand it to use in my query. kindly help me with this.

Hi,
In 11g you can use pivot.
[http://www.oracle.com/technology/pub/articles/oracle-database-11g-top-features/11g-pivot.html]
example
SQL> desc customers
Name                                      Null?    Type
CUST_ID                                            NUMBER(10)
CUST_NAME                                          VARCHAR2(20)
STATE_CODE                                         VARCHAR2(2)
TIMES_PURCHASED                                    NUMBER(3)
When this table is selected:
select cust_id, state_code, times_purchased
from customers
order by cust_id;
The output is:
CUST_ID STATE_CODE TIMES_PURCHASED
      1 CT                       1
      2 NY                      10
      3 NJ                       2
      4 NY                       4
... and so on ...
Note how the data is represented as rows of values: For each customer, the record shows the customer's home state and how many times the customer purchased something from the store. As the customer purchases more items from the store, the column times_purchased is updated.
Now consider a case where you want to have a report of the purchase frequency each state�that is, how many customers bought something only once, twice, thrice and so on, from each state. In regular SQL, you can issue the following statement:
select state_code, times_purchased, count(1) cnt
from customers
group by state_code, times_purchased;
Here is the output:
ST TIMES_PURCHASED        CNT
CT               0         90
CT               1        165
CT               2        179
CT               3        173
CT               4        173
CT               5        152
... and so on ...
This is the information you want but it's a little hard to read. A better way to represent the same data may be through the use of crosstab reports, in which you can organized the data vertically and states horizontally, just like a spreadsheet:
Times_purchased
             CT           NY         NJ      ... and so on ...
1             0            1          0      ...
2            23          119         37      ...
3            17           45          1      ...
... and so on ...
Prior to Oracle Database 11g, you would do that via some sort of a decode function for each value and write each distinct value as a separate column. The technique is quite nonintuitive however.
Fortunately, you now have a great new feature called PIVOT for presenting any query in the crosstab format using a new operator, appropriately named pivot. Here is how you write the query:
select * from (
   select times_purchased, state_code
   from customers t
pivot
   count(state_code)
   for state_code in ('NY','CT','NJ','FL','MO')
order by times_purchased
Here is the output:
. TIMES_PURCHASED       'NY'       'CT'       'NJ'       'FL'       'MO'
              0      16601         90          0          0          0
              1      33048        165          0          0          0
              2      33151        179          0          0          0
              3      32978        173          0          0          0
              4      33109        173          0          1          0
... and so on ...

Similar Messages

  • Is it possible to change the column headings when ever i execute the query

    in the runtime i want to change the column headings is that is possible.
    Ex: if write a timestampadd(.......) function in the table heading is that change the dates automatically whenever i execute the query?
    is this is possible?
    Product name 1-2-10 5-6-10
    aaaa 5 6
    bbfff 6 10

    Product name 1-2-10 5-6-10
    aaaa 5 6
    bbfff 6 10It looks like the dates are values in a column? Put that column in the Columns section of the Pivot Table and Product Name in the Rows section and it should produce what you are looking for.
    Edited by: David_T on May 19, 2010 2:33 PM

  • TO CHANGE THE COLUMN HEADING IN F4 HELP

    hi all,
    can anyone tell me ?
    How can we CHANGE THE COLUMN HEADING IN F4 HELP.
    If the F4 help is available for the custom field then i want to change the heading of the columns displayed in the F4 help.

    Hi,
    Kindly note that using ALL CAPITAL letters in subject line is against the
    Read the [Rules of Engagement|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement].
    Regards
    Karthik D

  • Need to change the column constrain from NOT NULL to NULL

    Hi,
    My requriment is I have to change the column constraint (NOT NULL) to NULLable (column having data), I used below query for that
    alter table table_name modify transaction_cost2 default null
    even command is successfull, but column constrain is still NOT NULL.
    can you any one help on this.. ( steps to change column constain from not null to null)
    Thanks,

    ALTER TABLE table_name
      MODIFY( transaction_cost2 NUMBER NULL )That assumes that the data type of the TRANSACTION_COST2 column is NUMBER-- you'll want to use the current data type if it is something else. I'm hoping that the fact that you have a column named TRANSACTION_COST2 doesn't imply that you have an incorrectly normalized data model. But the name of the column certainly implies that you do.
    Justin

  • Error while trying to change the Column description in Table Control

    Hi,
    I have created a table control using the wizard in Module Pool.
    When i try to change the column description of the table control or adjust any other element which is already available on the screen and not in table control. It gives me an error
    Unable to transfer data. End Program?
    Any help would be appreciated.
    Thanks
    Sarves S V K

    Hi.,
    Check these  [Table Control Change Column Description|Add new columns in table control in custom screen program;
    and  [Add Columns in Table Control|Re: Table control columns]
    else  delete and create Table control Again..!!
    hope this helps u.,
    Thanks & Regards,
    Kiran

  • Changing the column position & width using Screen Variant..

    Hi Experts,
        Iam trying to change the column position and width for the standard transaction (eg. FB60 or VA02) using the transaction code SHD0 (Transaction and Screen Variant).
        Iam able to create and save the transaction and screen variant and i could see the check box options for table control like
        a. Auto Column Position
        b. Auto Column Width
         I tried checking and unchecking both the check boxes but iam unable to modify / maintain the column position and width.
         Please guide me in changing the column position and width.
       Thanks in Advance.

    Hi Mudit,
    Kindly go through this link below:
    http://help.sap.com/saphelp_nw04/Helpdata/EN/9f/dbac0b35c111d1829f0000e829fbfe/content.htm
    Hope it helps you
    Regrds
    Mansi

  • How to change the column width in Smartforms..?

    Hi All..
    I need to change the column width in a smartform.
    The requirement has been mentioned as follows...
    Adjust the column width of the following columns:
    MATERIAL: 14 char
    DESCRIPTION: 20 char
    How to perform this..??
    Where can i find the column width of various columns of a smartform..???
    Please Help me...
    Regards
    Pavan

    In the SMART Forms, you would have created a Table object and specified the line width and divided that into no. of columns that you want, you have to mandatorily specify the width of each column so that total of column width will be equal to that of the line width.
    When you double click on the Table object, you can TABLE tab on the right side. If you can't see the line / columns details, click on the DETAILS button.
    Regards,
    Ravi
    Note - Please mark all the helpful answers

  • How to change the column header name dynamically based on sysdate

    Post Author: senthi_gokul
    CA Forum: WebIntelligence Reporting
    Dear All,
            i have designed some reports. i would like to change the column header dynamically based on sysdate. up to 24 months. can u help me, which add month function using the universe. i dont know if-then-else function is having the universe tool or not?

    Post Author: prasingh
    CA Forum: WebIntelligence Reporting
    Are you saying you are not able to create an object by value (select: statement) as sysdate and put it onto the headers of your report? You can use the add_months() function on the object to add the numbers of months you wish.
    Please let me knnow for more.. You can get in touch with me on [email protected] for quick reply. 

  • Changing the Column Header and Hiding the Column dynamically???

    Hi friends..
    I'm new to OBIEE field. I'm working in a OBIEE project that requires to dynamically change the column header, and dynamically hide the column depending on the prompt value.
    I know we can dynamically change the table header using the presentation variable but I couldn't do that same thing with column header.
    I searched some forums that suggest to use java script for this purpose but I'm not able to do the same also. If anyone had same issue before please help.

    toony, I'm not sure it's possible to do all that you want exactly the way you want, but here are some ideas you can pursue.
    To dynamically change column headers without javascript, check this blog out...
    http://oraclebizint.wordpress.com/2008/01/25/oracle-bi-ee-101332-dynamic-column-headers-using-presentation-variables-sets-and-conditional-formatting/
    As far as dynamically hiding a column, I don't think you can do this, but since you don't provide any details on how the PV is supposed to hide a column based on the value, are you talking about hiding a column for one PV value and another (different) column for a different PV value? Or are you talking about hiding one column when a PV has certain values and displaying it when the PV has a different set of values?
    I have managed to create both scenarios via a work-around, but the procedures require some writing so I don't want to put both. Please detail how you want your PV to "hide" a column or columns.
    P.S. I don't think column selectors will do the trick for you. Basically column selectors work like this: Say you have a report using Sales Region ID, Region Name, and Sales. Now let's say you want the user to choose if he/she wants to see annual sales, or quarter sales or weekly sales, etc. The column selector view would allow you to put the various columns (Year Sales, Quarter Sales, Weekly Sales) as an option the user can select. Once selected, the sales figure will change for the time period selected. For an example of how this is done, check out the section in this "Oracle by Example" link.
    Waited too long to publish this... Madan beat me to it, so there is some overlap here...
    http://www.oracle.com/technology/obe/obe_bi/bi_ee_1013/saw/saw.html
    Edited by: LC143 on Oct 27, 2008 9:21 AM

  • Change the column header according to the filter value ?

    Hello Experts,
    I have a requirement in which the customer wants to change the column header of the Sales Volume Key Figure to change according to the filter selected for the Calender Year / Month in the Free characteristics.
    I could display the header as 'Sales Volume for OCT 2000' as this is the value restricted intially in the free characteristics for Calender Year / Month.
    Any suggestion is appreciated.
    Thanks,

    Ioan Thanks for the reply.
    Probably my previous explanation of the problem was a little incomplete. Let me give a better description.
    The situation is something like this.
    I have a requirement in which the customer wants the column header to reflect the 'keep filter value' restriction that he does dynamically in the query report.
    i.e:
    -- usually the kf column header shows 'sales volume'
    -- column header with text variable of the Calender year / month variable -- 'sales volume for 2000 oct'
    -- but when the report is run, if the user wants to go and change the filter:   calender year / month > rt clk > keep filer value > select Jan 2003.
      The kf column header still shows 'Sales Volume 2000 Oct'
    How to make the column header change to 'sales volume for Jan  2003' ?
    Any suggestions greatly appreciated.
    Thanks,

  • Changing the column value

    Hi,
    I have to change the column values in a table. The values in the column are to be updated.
    For e.g. If the old value is
    "xxxxxxxxxx", I need to take that and update into "xxxyyyxxxx".
    The column values is so long as its a description field, so its a combination of many other table fields. Its just I need to add one more field.
    How can I do that? Any help appreciated.
    Thanks

    Hi,
    See this:
    I have got table with DESCRIPTION column which will be updated. Table structure is:
    SQL> DESC SOLD_ITEMS;
    Nazwa Wartość NULL? Typ
    COMPONENT VARCHAR2(255)
    SUBCOMPONENT VARCHAR2(255)
    YEAR NUMBER(4)
    MONTH NUMBER(2)
    DAY NUMBER(2)
    DEFECTS NUMBER(10)
    DESCRIPTION VARCHAR2(200)
    Table description contains values from (component, year, month, day & defects) column. I would like to add subcomponent value to this column.
    SQL> SELECT * FROM SOLD_ITEMS;
    COMPONENT SUBCOMPONENT YEAR MONTH DAY DEFECTS DESCRIPTION
    graph bar 2006 4 3 10 graph 2006/4/3
    graph bar 2006 4 1 1 graph 2006/4/1
    search user search 2006 4 2 23 search 2006/4/2
    search user search 2006 4 1 54 search 2006/4/1
    search product search 2006 3 20 0 search 2006/3/20
    search product search 2006 3 16 3 search 2006/3/16
    6 wierszy zostało wybranych.
    SQL> EDIT
    Zapisano plik afiedt.buf
    I use the SUBSTR and LENGTH function to place SUBCOMPONENT value between COMPONENT value and YEAR value. That's how I done it:
    1 UPDATE SOLD_ITEMS
    2* SET DESCRIPTION = SUBSTR(DESCRIPTION,1,LENGTH(COMPONENT)) || ' ' || SUBCOMPONENT || ' ' || SUBSTR(DESCRIPTION,LENGTH(YEAR))
    SQL> /
    6 wierszy zostało zmodyfikowanych.
    SQL> SELECT DESCRIPTION FROM SOLD_ITEMS;
    DESCRIPTION
    graph bar 2006/4/3
    graph bar 2006/4/1
    search user search 2006/4/2
    search user search 2006/4/1
    search product search 2006/3/20
    search product search 2006/3/16
    6 wierszy zostało wybranych.
    SQL> SPOOL OFF;
    Peter D.

  • How can i  change the column label text in a alv table display

    how can i change the column label text in a alv table display??
    A similar kinda of question was posted previuosly where the requirement was the label text was needed and following below code was given as solution :
    <i>*  declare column, settings, header object
    DATA: lr_column TYPE REF TO cl_salv_wd_column.
    DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    DATA: lr_column_header type ref to CL_SALV_WD_COLUMN_HEADER.
    get column by specifying column name.
    lr_column = lr_column_settings->get_column( 'COLUMN_NAME1' ).
    set Header Text as null
    lr_column_header = lr_column->get_header( ).
    lr_column_header->set_text( ' ' ).</i>
    My specific requirement is i have an input field on the screen and i want reflect that value as the column label for one of the column in the alv table. I have used he above code with slight modification in the MODIFYVIEW method of the view since it is a process after input. The component gets activated without any errors but while run time i get an error stating
    <i>"The following error text was processed in the system CDV : Access via 'NULL' object reference not possible."</i>
    i have checked in debugging and the error occured at the statement :
    <i>lr_column = lr_column_settings->get_column( 'CURRENT_YEAR' ).</i>Please can you provide me an alternative for my requirement or correct me if i have done it wrong.
    Thanks,
    Suri

    I found it myself how to do it. The error says that it is not able to find the reference object i.e  it is asking us to refer to the table. The following piece of code will solve this problem. Have to implement this in WDDOMODIFYVIEW method of the view. This thing works comrades enjoy...
      DATA : lr_cmp_usage TYPE REF TO if_wd_component_usage,
             lr_if_controller  TYPE REF TO iwci_salv_wd_table,
             lr_cmdl   TYPE REF TO cl_salv_wd_config_table,
             lr_col    TYPE REF TO cl_salv_wd_column.
      DATA : node_year  TYPE REF TO if_wd_context_node,
             elem_year  TYPE REF TO if_wd_context_element,
             stru_year  TYPE if_alv_layout=>element_importing,
             item_year  LIKE stru_year-i_current_year,
             lf_string    TYPE char(x),
      DATA: lr_column TYPE REF TO cl_salv_wd_column.
      DATA: lr_column_header TYPE REF TO cl_salv_wd_column_header.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    Get the entered value from the input field of the screen
    node_year  = wd_context->get_child_node( name = 'IMPORTING_NODE' ).
    elem_year  = node_year->get_element( ).
      elem_year->get_attribute(
       EXPORTING
        name = 'IMPORT_NODE-PARAMETER'
       IMPORTING
        value = L_IMPORT_PARAM ).
      WRITE L_IMPORT_PARAM TO lf_string.
    Get the reference of the table
      lr_cmp_usage  =  wd_this->wd_cpuse_alv( ).
      IF lr_cmp_usage->has_active_component( ) IS INITIAL.
        lr_cmp_usage->create_component( ).
      ENDIF.
      lr_if_controller  = wd_this->wd_cpifc_alv( ).
      lr_column_settings = lr_if_controller->get_model( ).
    get column by specifying column name.
      IF lr_column_settings IS BOUND.
        lr_column = lr_column_settings->get_column( 'COLUMN_NAME').
    set Header Text as null
        lr_column_header = lr_column->get_header( ).
        lr_column_header->set_text( lf_string ).
    endif.

  • Change the column width on the fly

    Dear all,
    I have a problem, i have a matrix report, the row is "the project name" and the column is "the items" using within each project, and the problem is the items are variable from time to time the report run for each project, so its exceeds the paper width.
    And the question is, is there any way to change the width of the column on the fly, i mean dynamiclly change the column width each time the report is called to make all items fit the paper width.
    Thank u

    i don't think that we can change the layout of the column in reports
    The simple solution for that problem is that u have to
    fix the horizontal and vertical layout of the text item
    better is to post this problem at reports forum
    Najeeb

  • How do I convert a pdf-presentation into Powerpoint, which it is said that I can do? I can convert into Word, but that is of no help as I need to change the text in the document.

    How do I convert a pdf-presentation into Powerpoint, which it is said that I can do? I can convert into Word, but that is of no help as I need to change the text in the document.

    Hi Sara!
    Yes this sounds interesting. Can I update to that from the PDF Export I have just renewed? How much would that cost?
    Thanks for your quick answer.
    Best Regards
    Per-Olof Egli                                         Logga Egli C.I.S
    Managing Director
    Egli C.I.S. Consulting
    Lapphundsgränd 43
    SE-128 62 SKÖNDAL
    Sweden/Швеция
    Phone:         +46 708 23 03 53
    <http://www.eglicisconsulting.se/> www.eglicisconsulting.se
    <mailto:[email protected]> [email protected]
    Skype: eglipo
    Från: Sara.Forsberg 
    Skickat: den 10 september 2014 22:11
    Till: P-o Egli
    Ämne:  How do I convert a pdf-presentation into Powerpoint, which it is said that I can do? I can convert into Word, but that is of no help as I need to change the text in the document.
    How do I convert a pdf-presentation into Powerpoint, which it is said that I can do? I can convert into Word, but that is of no help as I need to change the text in the document.
    created by Sara.Forsberg <https://forums.adobe.com/people/Sara.Forsberg>  n Adobe ExportPDF - View the full discussion <https://forums.adobe.com/message/6718870#6718870>

  • Can anyone help me, I need to change the address (country) from US to UK so i can purchase?

    can anyone help me, I need to change the address (country) from US to UK so i can purchase?

    Change/Verify Account https://forums.adobe.com/thread/1465499 may help
    -http://helpx.adobe.com/x-productkb/policy-pricing/change-country-associated-with-adobe-id. html

Maybe you are looking for