How to make pivot table in query ?

Hi all,
SELECT COUNT(C.entity_id) as Entity_Id,
  e.description       AS region,
  d.business_initials AS business_group
FROM
  (SELECT a.entity_id ,
    a.region,
    B.business_group
  FROM ms_fcr_entity_reg a,
    ms_fcr_entity_bus b
  WHERE a.entity_id         = b.entity_id
  AND B.business_group NOT IN ('Citi Commercial Bank - (CCB)','Global Consumer Group - (GCG)')
  ) C,
  ms_fcr_business_group_data d,
  ms_fcr_managed_geography e
WHERE C.region       = e.managed_geography_id
AND C.business_group = d.business_group_id
group by E.DESCRIPTION,
  d.business_initials;
my out put is like this
entity_id region  businessgroup
190        NAM    CCB
40           NAM    COR
106          NAM    CPB
189          NAM    GCG
168           NAM    ICG
40             NAM    MLS
but i need output like this
REGION    BG(CCB)  BG(COR)  BG(CPB) BG(GCG) BG(ICG) BG(MLS)
NAM           190             40              106          189           168          40
Thanks
Damby

Try the below
SELECT region,
              MAX(DECODE( business_group,'CCB',Entity_id)) "BG(CCB)",
              MAX(DECODE( business_group,'COR',Entity_id)) "BG(COR)",
              MAX(DECODE( business_group,'CPB',Entity_id)) "BG(CPB)",
              MAX(DECODE( business_group,'GCG',Entity_id)) "BG(GCG)",
              MAX(DECODE( business_group,'ICG',Entity_id)) "BG(ICG)",
              MAX(DECODE( business_group,'MLS',Entity_id)) "BG(MLS)"
FROM (SELECT COUNT(C.entity_id) as Entity_Id,
  e.description       AS region,
  d.business_initials AS business_group
FROM
  (SELECT a.entity_id ,
    a.region,
    B.business_group
  FROM ms_fcr_entity_reg a,
    ms_fcr_entity_bus b
  WHERE a.entity_id         = b.entity_id
  AND B.business_group NOT IN ('Citi Commercial Bank - (CCB)','Global Consumer Group - (GCG)')
  ) C,
  ms_fcr_business_group_data d,
  ms_fcr_managed_geography e
WHERE C.region       = e.managed_geography_id
AND C.business_group = d.business_group_id
group by E.DESCRIPTION,
  d.business_initials) GROUP BY region;

Similar Messages

  • How to get pivot table by using dates

    Hi,
    How to get pivot table by using dates in column.
    Below is the sample table and its value is given.
    create table sample1
    Order_DATE       DATE,
    order_CODE       NUMBER,
    Order_COUNT   NUMBER
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),1,232);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),2,935);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),3,43);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),4,5713);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),5,11346);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),1,368);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),2,1380);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),3,133);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),4,7109);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),5,14336);
    select * from sample1;So how to get the data like below.
              order_date
    order_code 30-sep-12 29-sep-12
    1 232 368
    2 935 1380
    3 43 133
    4 5713 7109
    5 11345 14336

    Using the extra data I inserted in my previous reply:select ORDER_CODE,
    SUM(DECODE(extract (month from ORDER_DATE),1,ORDER_COUNT,0)) JAN,
    SUM(DECODE(extract (month from ORDER_DATE),2,ORDER_COUNT,0)) FEB,
    SUM(DECODE(extract (month from ORDER_DATE),3,ORDER_COUNT,0)) MAR,
    SUM(DECODE(extract (month from ORDER_DATE),4,ORDER_COUNT,0)) APR,
    SUM(DECODE(extract (month from ORDER_DATE),5,ORDER_COUNT,0)) MAY,
    SUM(DECODE(extract (month from ORDER_DATE),6,ORDER_COUNT,0)) JUN,
    SUM(DECODE(extract (month from ORDER_DATE),7,ORDER_COUNT,0)) JUL,
    SUM(DECODE(extract (month from ORDER_DATE),8,ORDER_COUNT,0)) AUG,
    SUM(DECODE(extract (month from ORDER_DATE),9,ORDER_COUNT,0)) SEP,
    SUM(DECODE(extract (month from ORDER_DATE),10,ORDER_COUNT,0)) OCT,
    SUM(DECODE(extract (month from ORDER_DATE),11,ORDER_COUNT,0)) NOV,
    SUM(DECODE(extract (month from ORDER_DATE),12,ORDER_COUNT,0)) DEC
    from SAMPLE1
    where trunc(order_date, 'YY') = trunc(sysdate, 'YY')
    group by order_code
    order by order_code;
    ORDER_CODE JAN FEB MAR APR MAY JUN JUL AUG   SEP   OCT NOV DEC
             1   0   0   0   0   0   0   0   0   600   600   0   0
             2   0   0   0   0   0   0   0   0  2315  2315   0   0
             3   0   0   0   0   0   0   0   0   176   176   0   0
             4   0   0   0   0   0   0   0   0 12822 12822   0   0
             5   0   0   0   0   0   0   0   0 25682 25682   0   0Now a bit of explanation.
    1) Whenever you pivot rows to columns, no matter what version of Oracle and no matter what method you use, you have to decide in advance how many columns you are going to have and what the names of the columns are. This is a requirement of the SQL standard.
    2) I use the WHERE clause to get just the data for this year
    3) With EXTRACT, I get just the month without the year.
    4) Using DECODE, I put every month's data into the correct column
    5) Once I do all that, I can just GROUP BY order_code while SUMming all the data for each month.

  • How to make the table scalable inside a tap control?

    Hi,
    Does anyone know how to make the table scalable inside a tap control in LabWindow CVI? I see that there is option for a panel to scale contents on resize, but not available for a tab control. Any ideas?
    Thanks a lot!
    Weiming
    Solved!
    Go to Solution.

    Hi SGIE,
    you have posted a LV-related question to the LabWindows/CVI forum: you should post it in the LabVIEW forum instead.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How to make stork table in Mac numbers

    hello,
    how how to make stork tables in numbers just as what we can creat in windows excel?
    thank you

    Another way to create this type of chart is to create the pieces in separate charts and then layer them. 
    You create two stacked bar charts.  There are two rows of values in each.  The color of the bottom value is set to "no fill" to create the floating bar effect. 
    The width of the stick bar is changed by setting the gap to the maximum allowable (999%).  The "stick" chart is placed behind the other.
    For this to work, they need to be the exact same size and with the same axis values.  Setting the axis to have fixed values makes this easier.  Also, it improves the appearance to limit all the axis labels and lines to be in just one of the charts.

  • Well how I make Rounded Table Corners (html) ?

    I use dmwr mx 2004 , well how I make Rounded,Table,Corners
    (html) ? CSS TABLES can be with Rounded Corners ?

    On Wed, 12 Dec 2007 16:40:01 +0000 (UTC), "123polis123"
    <[email protected]> wrote:
    >I use dmwr mx 2004 , well how I make
    Rounded,Table,Corners (html) ? CSS TABLES can be with Rounded
    Corners ?
    No - you have to use images.
    as already said - just google for more info
    http://www.google.co.uk/search?hl=en&q=round+corners+on+websites&btnG=Google+Search&meta=
    ~Malcolm N....
    ~

  • Can any one tell how to create pivot table

    Hi ,
    Am trying to create a pivot tabel in the MDM Import Manager. Iam able to see the preview of the pivot table which i want to create. But when i try to click "OK" button, an error message getting displayed like...
    "The new table cannot be created because the data source is not updatable.You may need the data source to an updatable format such as Microsoft Access before proceeding".
    Due to the above error am not able to create pivot table, plz let me know if any one know how to solve this problem
    Thanks & regards
    Praveen k

    Hi Praveen ,
       The solution to your problem is -
    The data source must be updateable in order for MDM to
    create the new pivot or reverse pivot table. However, you can still
    perform the steps leading up to table creation – including the preview –
    even on a data source that is not updateable, so that you can explore
    pivoting or reverse pivoting as a transformation option. If you then
    decide you want to actually create the new table, convert the data
    source into a format that is updateable (such as Microsoft Access) and
    perform the pivot or reverse pivot on the new data source.
    To create a pivot table, you must identify the source fields that
    participate in the pivot, which ones contain metadata and which ones
    contain data, which ones must be combined, the one-to-one
    correspondence between metadata and data fields and/or field
    combinations, and the key field or fields.
    To create a pivot table:
    1. In the drop-down list of source tables, make sure the table you want to
    pivot is the current source table.
    2. In the Source Hierarchy tree, select all the field nodes corresponding to
    both the metadata fields and the data fields by which you want to pivot.
    3. Right-click on one of the nodes and choose Create Pivot Table from the
    context menu, or choose Source > Create Pivot Table from the main
    menu
    4. MDM opens the Create Pivot Table dialog
    5. In the Key Fields dual-list drop-down control, move one or more fields
    from the Available Fields list to the Selected Fields list to identify the
    key fields on which to perform the pivot
    6. In the dual-list control of fields, drag-and-drop the data fields from the
    Field Values Become Field Names list to the Field Values Become
    Field Values list
    7. If necessary, select two or more fields in either list that must be
    combined into a field combination, and click on the Combine button, or
    right-click on one of the fields and choose Combine from the context
    menu
    8. If necessary, drag-and-drop fields or field combinations within each list
    to create the one-to-one correspondence between metadata fields and
    data fields.
    9. Click on the Preview button to display a preview of the first ten records
    of the pivot table
    10. When you have verified that the pivot operation you have defined will
    have the desired effect, click OK to close the Create Pivot Table dialog.
    11. The MDM Import Manager creates a new table named “table <Pivot>”
    in the data source (where “table” is the name of the original source
    table).
    12. In the drop-down list of source tables, select the newly created pivot
    table on which to perform subsequent import processing.
    Hope that helps ...
    Regards
    Deepak Singh

  • How to make changes in infose query in SQ01

    Dear experts,
    I hv question abt infoset query.
    I m not very familiar with infoset query and now i hv to make some changes in already existing query.
    I hv found the infoset in use.
    from this infoset i can find the query.
    Now the question is I just hv to insert one field in selection screen and and same in output list. This field has to come from a table which is already in use in joins. I just have to tick the checkbox to appear the field in selection screen and in outputlist.
    But I m not sure, if i make any changes in query, what will be the effects because the query is in production system and i hv to make changes in the production system only.
    and before sq01 i hv to drag and drop that field in infoset sq02..
    Can any one pls guide me , how i should make changes in query.
    Thanks in advance
    Jaspal Kumar
    Edited by: jaspalkumar on Feb 25, 2011 10:43 AM

    Thank you very much for ur reply.
    Actually, there are tjhree table joined in sq02.  One is KNVV. i hv to add customer group into selection screen and output list also.
    SO i will hv to make changes both in sq02 and then sq01.
    how i supposed to do it.   I m very sory asking again and its like spoon feeding,
    but to be very true report is in production and i m very scared of ripple effects of changes as i hv less idea abt the infoset.
    Pl;s guide,
    With best regards,
    Jaspal Kumar

  • How to make a table editable?

    hi all,
    do u know how to make a (ABAP Webdynpro ESS screen)  table editable?
    is it through ALV or Table ?
    thanks

    Hi,
    actually to make the table activated u have to append initial lines to ur table.so first make an internal table like of ur node then append initial lines to this and then bind it to the node.code is given below.in case of further query u can ask me.
    DATA lo_nd_cn_dartdetails TYPE REF TO if_wd_context_node.
      DATA lo_el_cn_dartdetails TYPE REF TO if_wd_context_element.
      DATA ls_cn_dartdetails TYPE wd_this->element_cn_dartdetails.
      DATA lt_table TYPE wd_this->elements_cn_dartdetails.
      DATA ls_table TYPE wd_this->element_cn_dartdetails.
    navigate from <CONTEXT> to <CN_DARTDETAILS> via lead selection
      lo_nd_cn_dartdetails = wd_context->get_child_node( name = wd_this->wdctx_cn_dartdetails ).
      do 5 times."(as many lines u want)
        append ls_table to lt_table.
      enddo.
      lo_nd_cn_dartdetails->bind_table( lt_table ).

  • How to prevent Pivot Table Data Source from being changed automatically?

    I have an excel file that contains a Pivot Table that references a table within the workbook (Data Source = "MyTable").  When I save the file and copy it, the copy contains a reference to the original file.  Instead of displaying, "MyTable",
    it shows  "OldFilename!MyTable" where OldFilename is the name of the original file, not the current file.
    How do I prevent this from occurring.  It is only doing this on my current machine, if I perform these steps on a different machine, the problem does not occur and the Data Source property stays the same as it should.
    What setting(s) do I change to fix this problem?
    Thank you in advance for your help!
    Michael

    Hi Michael,
    How about the issue now, is it solved?For the 'data model' feature,please refer to:
    http://blogs.office.com/2012/08/23/introduction-to-the-data-model-and-relationships-in-excel-2013/
    let us know if you have any additional questions or concerns.
    Best regards,
    Wind

  • How to make a table in java without using GUI??

    how can i make a table in java without usinf GUI, just simple codes??
    NAME ID NUMBER ADDRESS STATUS

    If you simply want to store them internally, you don't want to use a table.
    Make a simple class with properties id, name, number, address, status. Then create a Hashtable that indexes instances of the class by id or some other property.

  • How to make a table color or back ground image go on forever

    How do I make a table go on forever (to the right)? I know
    you can edit the size of the table, but if you make it larger than
    your own computer screen it makes you have to scroll left and
    right. I want to know how do I make a table go on forever with out
    making someone with a small screened computer have to scroll left
    and right.
    Thanks.,

    You can't. What is it you are trying to accomplish?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "-Michael--" <[email protected]> wrote in
    message
    news:eddbh5$a45$[email protected]..
    > How do I make a table go on forever (to the right)? I
    know you can edit
    > the
    > size of the table, but if you make it larger than your
    own computer screen
    > it
    > makes you have to scroll left and right. I want to know
    how do I make a
    > table
    > go on forever with out making someone with a small
    screened computer have
    > to
    > scroll left and right.
    >
    > Thanks.,
    >

  • How to disable Pivot Table Prompt ability to move into sections?

    Pivot Table Prompts can be moved to sections when report is running. How can the ability to move the prompts be disabled?
    When running the analysis, hover near the beginning of the prompt to get the arrows.
    Can then drag and drop the prompt into another section of the report.
    Can also do the same and move it back up into the prompt, but users sometimes accidentally move the prompt and can't get it out of the section.
    How can the drag and drop of the pivot table prompts be disabled?
    Thanks

    Darren Gosbell,
    Thanks for your reply.
    Item_Name
    Category
    Vendor
    Sales_Amount
    Item 1
    Category 1
    Vendor 1
    30
    Item 2
    Category 1
    Vendor 2
    25
    Item 3
    Category 2
    Vendor 3
    50
    Item 3
    Category 2
    Vendor 3
    60
    Item 3
    Category 2
    Vendor 3
    20
    Item 2
    Category 1
    Vendor 2
    10
    Item 2
    Category 1
    Vendor 2
    30
    Item 2
    Category 1
    Vendor 2
    100
    Item 2
    Category 1
    Vendor 2
    20
    Item 4
    Category 1
    Vendor 2
    3
    Item 4
    Category 1
    Vendor 2
    50
    Item 4
    Category 1
    Vendor 2
    3
    The above is my new source data.
    I used this function to calculate  Rank:=RANKX(ALL(Sales[Item_Name]),[Sum of Sales_Amount])
    and also used yours below:  
    Rank2:=RANKX(SUMMARIZE(ALL(Sales),[Item_Name],[Category]),CALCULATE([Sum of Sales_Amount],ALLEXCEPT(Sales,Sales[Item_Name],Sales[Category])))
    The Preceding screenshot is the result of our two function but i wanna pivot table like shown below:
    Could please help me to fix it out.

  • How to make a table field Required

    Hi,
    I tried to make a table field as 'Required'. It works fine. But it gives unexpected results. Imagine the table has 10 rows. when the user make an entry in the first row, the system gives the error messages for the required field in the remaining rows as well. How can we restrict it so that it checks for the required field only for the row with entries. How to specify the condition type?
    Kind Regards
    Shahul

    Hi,
    check this :
    don't set table field as 'Required'.If your table data contains in a internal table , then use Below code under <b>PAI</b> event.
      LOOP AT i_data.
        CHAIN.
          FIELD:  i_data-fld1.
          MODULE validate_field.
        ENDCHAIN.
      ENDLOOP.
    MODULE validate_field INPUT.
    write the code to validate the each line of the table control, if validation fails , cursor will stop at the table control row
    ENDMODULE.
    Regards
    Appana

  • How to make a table control header become two rows?

    Hi, all.
    May I know how to make the static header/label rown in table control on screen become two rows?
    As we know, normally a table control's first row is header, and starting from the second row onwards are it's content or data. So, now I would like to make the hedear/label become first two rows.
    Anyone know about it?
    Thanks in advance.

    Hai Lim,
    Kindly search in SDN.
    "You can't actually have two lines but you can create a title which you may be able to align with the headings to achieve what you want. On the table control tick the 'w/title' box. It then forces you to put an element into a line at the top of the table control."
    Regards,
    Harish

  • HELP! How to make RRI from BEX query into Workbook with one report???

    How to make RRI from query into Workbook???

    Hi Alex,
    A workbook is a set format of queries, so when you try to jump to another query , you will definitely open another session and hence another excel file. This is the same for web templates also though you have an option of opening the new result in the same window.
    You would have to use some macros and open the query on the same page. A RRI is a query jump and not a drill down . A drill down would be getting more of the dimensions into the query.
    Regards
    CSM Reddy

Maybe you are looking for

  • Hang Ups

    Is anybody else having problems with SL hanging up applications...even when you really aren't doing anything? I've been hanging up with Firefox, Safari, iTunes and iChat. I'm new to the mac world and this is my first upgrade. The install was seemless

  • Exception handling in an RFC server

    Hi,    I've an RFC server coded in vb.net.  Am trying to capture the exceptions raised by the server in an ABAP program.  But it is giving a short dump.  Can any one tell me the reason for this?  Regards, Aravinda Sarma M. The following is the code:

  • Problem exporting video using compressor for a final cut pro vid

    I've created a video in Final Cut Pro and trying to export using compressor to apple tv. Each time about half way through it crashes final cut and gives me the 'final cut pro had to quit unexpectedly'. Haven't a clue what is going on, it happened som

  • Substitution for SDM

    Hi all, for development purposes we used the remote SDM API to deploy new development stuff to our J2EE instances. But with NetWeaver CE 7.1 SDM is obsolete. Is there another remote API, for example for JSPM or NWA? Thanks in advance Markus

  • Do NOT share the JSP Working Directory among WL instances

              Somewhere in the WLS documentation it says it's ok to share           directories among WLS instances in a cluster.           It is NOT OK to share the JSP Working Directory because the           instances are not synchronized about compili