Rows To Columns Or Pivot Table with SQL Model over two tables

hi @all
oracle 10.2.0.4
i have following situation
table_1
t1_id   t1_name
1      reggie
table_2
t2_id   t2_t1_id   t2_start_date   t2_end_date
1      1      01.01.2008      31.03.2008
2      1      01.06.2008      31.07.2008
cardinality from table_1 to table_2 is one to many
now i need this
t1_name   t2_start_date_1   t2_end_date_1   t2_start_date_2   t2_end_date_2   t2_start_date_x   t2_end_date_x
reggie      01.01.2008      31.03.2008      01.06.2008      31.07.2008
i think the max occurrence of start/enddate can be 15
can somebody help

Hello,
One way, assuming 15 is the maximum:
SELECT t1.name,
        t2.t2_start_date t2_start_date_1,   t2.t2_end_date t2_end_date_1,
        LEAD(t2.t2_start_date,1) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date) t2_start_date_2,
        LEAD(t2.t2_end_date,1) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_2,
        LEAD(t2.t2_start_date,2) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_3,
        LEAD(t2.t2_end_date,2) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_3,
        LEAD(t2.t2_start_date,3) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_4,
        LEAD(t2.t2_end_date,3) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_4,
        LEAD(t2.t2_start_date,4) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_5,
        LEAD(t2.t2_end_date,4) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_5,
        LEAD(t2.t2_start_date,5) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_6,
        LEAD(t2.t2_end_date,5) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_6,
        LEAD(t2.t2_start_date,6) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_7,
        LEAD(t2.t2_end_date,6) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_7,
        LEAD(t2.t2_start_date,7) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_8,
        LEAD(t2.t2_end_date,7) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_8,
        LEAD(t2.t2_start_date,8) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_9,
        LEAD(t2.t2_end_date,8) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_9,
        LEAD(t2.t2_start_date,9) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_10,
        LEAD(t2.t2_end_date,9) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_10,
        LEAD(t2.t2_start_date,10) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_11,
        LEAD(t2.t2_end_date,10) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_11,
        LEAD(t2.t2_start_date,11) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_12,
        LEAD(t2.t2_end_date,11) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_12,
        LEAD(t2.t2_start_date,12) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_13,
        LEAD(t2.t2_end_date,12) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_13,
        LEAD(t2.t2_start_date,13) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date)t2_start_date_14,
        LEAD(t2.t2_end_date,13) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date)t2_end_date_14,
        LEAD(t2.t2_start_date,14)  OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_start_date) t2_start_date_15,        
        LEAD(t2.t2_end_date,14) OVER (PARTITION BY t2.t2_t1_id ORDER BY t2.t2_end_date) t2_end_date_15
  FROM table_1 t1
  JOIN table_2 t2 ON (t1.t1_id = t2.t2_t1_id)
WHERE (t2.t2_start_date,   t2.t2_end_date) IN (
  SELECT MIN(t2_start_date), MIN(t2_end_date)
    FROM  table_2 t22
  WHERE t2.t2_id = t22.t2_id);
Edit
Fixed incomplete code

Similar Messages

  • Mimic "show data as percent of row parent" in non-pivot table

    Is it possible to implement or mimic the 'percentage of parent row' functionality, foreseen for pivot tables in obiee 11g, for a 'normal' table?
    We use a rather fixed table, in which no drilling is allowed - conditions are applied by means of prompts and filters. The report is based upon the store dimension, which has as hierarchy: country > cluster > store. We have added a column to represent the 'share' of a store's net turnover in the cluster total. The results looks like:
    country  cluster  store  turnover   share
    =======  =======  =====  ========   =====
    belgium  1        a        20.000   66.7%
                      b        10.000   33.3%
             cluster total:    30.000  100.0%
             2        c        40.000   57.1%
                      d        30.000   42.9%
             cluster total:    70.000  100.0%
    country total:            100.000  100.0%
    holland  3        e        50.000   71.4%
             4        f        20.000   28.6%
             cluster total:    70.000  100.0%
    country total:             70.000  100.0%
    grand total:              170.000  100.0%Instead of all the total levels showing as 100% however, we would like to see each sub-total represented as a percentage of the level above, much like the forementioned pivot table functionality. For the example above that would mean it should look like:
    country  cluster  store  turnover   share
    =======  =======  =====  ========   =====
    belgium  1        a        20.000   66.7%
                      b        10.000   33.3%
             cluster total:    30.000   30.0%
             2        c        40.000   57.1%
                      d        30.000   42.9%
             cluster total:    70.000   70.0%
    country total:            100.000   58.8%
    holland  3        e        50.000   71.4%
             4        f        20.000   28.6%
             cluster total:    70.000  100.0%
    country total:             70.000   41.2%
    grand total:              170.000  100.0%Any advice or idea would be greatly appreciated...

    902360 wrote:
    Hello,
    I'd like to know if there's a way to configure the Pivot Table "Show Data As - Percent of" precision.
    ATM, I have some reports using SR types where one of those are much bigger than the others.. So when the report its generated, it returns something like:
    TYPE A: 99%
    TYPE B: 0%
    TYPE C: 0%
    TYPE D: 0%
    How can I show the other types correct value? Something like number of decimal places...
    Ps: As criteria to this report, I have changed my Data Format to "Number", "Minus: -123" with 15 Decimal Places.
    Thanks,
    RamonYup. Can do. Read this link:
    http://shivabizint.wordpress.com/2008/09/14/changing-the-precession-of-percent-of-columns-in-pivot-table-of-obiee/

  • How to convert rows to columns of a table?

    I want to convert rows to columns of a table..
    Query in SQL??

    965373 wrote:
    I want to convert rows to columns of a table..
    Query in SQL??PIVOT by Frank Help for a query to add columns
    PIVOT by TomK http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:766825833740

  • Calculation on two columns in pivot table

    Hello all,
    I have a view:
    Dept Year Amount
    Accounting $500 2010
    Accounting $700 2011
    Engineering $100 2010
    Engineering $600 2011
    and etc
    pivot table:(data displayed side by side)
    Dept: 2010 2011
    Accounting $500 $700
    Engineering $100 $600
    Is there a way in pivot table to create additional column and do a calculation on that column? New column called 'Change' (actual calculation amount of 2010 minus amount of 2011 per each department). I see the feature which allows to duplicate the columns in pivot table. But this is it... no additional calculations.
    Thank you in advance,
    Sonya

    Deepak,
    My "YEAR_NO' is already in the column area. Once I created 'calculated column' and entered formula '2011'-'2010' I got what I needed.
    Thank you very much for the solution.
    Sonya
    In my view I also have column called EXPENSE. When, I added the 'calculated column' to 'YEAR_NO' with formula '2011'-'2010'. It created two calculated columns 1) after the EXPENSES and the other one after YEAR_NO. Is there a way to be specify to display the DIFFERENCE only once after the YEAR_NO??
    Edited by: user8461308 on Dec 20, 2011 7:44 AM

  • Calculated Percentage Columns in Pivot Table loose formating in Excel

    I have a simple report built using pivot table ( OBIEE 11.1.1.5.0)
    1 Metric and 1 dimension using pivot table. and I duplicated the metric column and change it to % column.(Show data as % of column). SO far so good. Below is the snapshot
    http://tinypic.com/r/2s14xa9/7
    Now i download the report in excel and all the % values are messed up . Below is how it looks
    http://tinypic.com/r/bede90/7
    I tried messing with data formats etc..nothing works.. I cannot add a custom column format to the metric column since it will impact the derived % column.
    Is this a bug ?Any pointers ..
    Thanks

    Hi,
    Follow up this SR:
    SR 3-5060435331: Calculated Percentage Columns in Pivot Table loose formating in Excel
    Workaround: (not sure may be give a try)
    also give a try like below one then try to download it may work.
    In that % column -->add the below statement in the Custom CSS section of the column properties:
    mso-number-format:"\@"
    Refer snapshot here:
    http://i53.tinypic.com/a09kqv.jpg
    This will treat the data in the column as text while downloading to excel, hence retaining any leading or trailing spaces.
    Thanks
    Deva

  • How to extend No. of columns for PIVOT table in BI Publisher Desktop

    Hello Everyone,
      I am using the Oracle BI Publisher Desktop to design the TEMPLATE for Oracle Reports.
    I need to create the PIVOT table .In my PIVOT table I need to display 9 columns but when I tried to create PIVOT table by dragging 9 columns only first 4 columns are displaying in report.
    Can anyone suggest me how can I increase the number of columns in PIVOT table?
    Thank You.
    Regards,
    Guru.

    hi jim
    if you carefully look inside the form field's you will find the logic of sort . if you remove that you will get the data without any sorting order.
    else send me your template and xml to my email id i can look into that .
    email : [email protected]

  • How can we modify the maximum no. of columns in pivot table ?

    hi all,
    How can we modify the maximum no. of columns in pivot table ?
    do i need to change the nqconfig.ini or instanceconfig file or else?
    thnx..

    A little search on the forum :
    In the instanceconfig.xml add a <PivotView> element under <ServerInstance> if one does
    not exist already.
    Within the <PivotView> element add an entry that looks like:
    <MaxCells>nnnnnn</MaxCells>
    where nnnnnn is your desired limit for the maximum total number of cells allowed
    in a pivot.
    Warning: an excessively large number will cause more memory consumption and
    slower browser performance.The details here :
    Oracle BI EE (10.1.3.2): Maximum total number of cells in Pivot Table excee

  • Report totals with dimension hierarchy column on pivot table incorrect

    Hi,
    I have a pivot table based report that has one dimension column, a dimension hierarchy column and various measures.
    The row totals do not match, detail to total, and I have tried both complex server based aggregate and report based aggregation, but neither are giving me the correct answer.
    I have also tried adding the column that is the same as the top level as the hierarchy, but hidden, but this does not help.
    I have also tried adding the lowest level of detail column, but hidden, but this does not give me the solution I need as all of the figures then appear at detail not aggregated level.
    Any ideas please?
    thanks,
    Robert.

    Can you validate the query hitting to the database and compare the results?
    Mark if helps.
    Thanks,

  • Suppressing Columns in Pivot table when adding subtotal

    Hi,
    We have a dimension hierarchy like this:
    Level 1 ---> Level 2 ---> Level 3
    T ---> A ----> B1
    T ---> A ----> B2
    T ---> C ----> D
    T ---> E ----> E
    The report we are trying to build is of this format:
    Row_Num --> Dimension --> Amount
    1 --> B1 ---> 100
    2 --> B2 ---> 50
    3 --> A ---> 150
    4 --> D ---> 75
    5 --> C ---> 75
    6 --> E ---> 100
    When using Pivot table and subtotals, we are getting the report as below: (where for Dimension Value "E" there are two rows)
    Row_Num --> Dimension --> Amount
    1 --> B1 ---> 100
    2 --> B2 ---> 50
    3 --> A Total ---> 150
    4 --> D ---> 75
    5 --> C Total ---> 75
    6 --> E ---> 100
    7 --> E Total ---> 100
    We do not want the subtotals to be calculated if Level 2 and Level 3 are the same.
    Any ideas on how to achieve this?
    Many Thanks,
    Seetharam

    Hi user7276913,
    Are you sure you are using a Pivot Table view? Or are you using the standard table view?
    In a pivot table, you can only have (n-1) sub-totals where n is the number of fields in your "Rows" section. So in your case you have two fields, so you can only have 1 sub-total. See my screen shot below where I have a similar situation:
    !http://i47.tinypic.com/icux5y.png!
    Note that in the screen shot only the first column has a summation and the second does not. This makes sense since a sub-total and the last column would be the same as the values being displayed in the "measures" section.
    What you described in your post seems more like what I'm seeing in a standard table view
    !http://i48.tinypic.com/34z12zp.png!
    Based upon what I'm seeing in your sample report, it seems like you are missing some kind of line item number or transaction number or some field that uniquely determines a row. If you add this field into the pivot table you will get exactly what you want.
    e.g. Pivot Table Rows = Customer # (with summation Enabled) , Document Type (Summation Enable), Line Number
    Good luck and if you found this post useful, please reward points!
    Best regards,
    -Joe

  • Formating column in Pivot Table (Hyperion Interactive Reporting 9.3.1)

    I have a simple pivot table with multiple columns (8) and I have 6 different pivots. I drag the pivots into the report section, but none of the column widths or row heights align properly.
    How do you size the column widths in each pivot and I'm trying to avoid auto-size because that does not get it right.
    Thanks,

    The 6 pivots are different because the rows indicate something entirely different. for example:
    Pivot 1:
    Row Label: Customer Gender
    Column Label: Quarters (1-4)
    Facts: Sales
    Pivot 2.
    Row Label: Customer ethnicity
    Column Label: Quarters (1-4)
    Facts: Sales
    Pivot 3.
    Row Label: Customer Age group
    Column Label: Quarters (1-4)
    Facts: Sales
    Pivot 4.
    Row Label: Customer City
    Column Label: Quarters (1-4)
    Facts: Sales
    Then I grab each pivot and drag them into the report section to create 1 report.
    A better solution?

  • Running sum per column in pivot table

    Hello,
    I am facing a problem with a running sum in a pivot table. As you know, the running sum provided by OBIEE spans across rows and columns. My requirements force me to have a running sum per each column (I have four columns, one for each quarter of the year). My pivot is as follows:
    ------------------------------|| 1st Quarter / 2nd Quarter ...
    type of product / status || (Measure / Running Sum) / (Measure / Running Sum) ...
    I've tried using the evaluate function with a "sum over" but that doesn't seem to work either.
    Do you have any ideas that could be useful to solve this?
    Thank you in advance for your time,
    João Marques

    Do not use the "running measure" button in pivot table, but try this :
    edit the formula of your measure and type :
    RSUM(mesure by dimension)
    where dimension is the attribute dimension that you put on the ROWS of your pivot table
    Exemple : I've got the criteria REVENUE, YEAR, CUSTOMER TYPE
    I put the YEAR in the Columns of the pivot table
    I put the CUSTOMER TYPE on the rows of the pivot table
    I put the REVENUE in the measures of the pivot table
    Measure has the formula : RSUM("Facts Revenue".Revenue BY Customers."Customer Type")

  • No data for Parent-child hierarchy column in Pivot table view

    Hi all,
    I used OBIEE 11.1.1.6.2 Version.
    I drag one Parent-child hierarchy column and one measure and show result with a pivot table view.
    But when I click "+" icon to show detail level data,
    It messaged that: "*the layout of this view combined with the data,selections,drills,or prompt values chosen resulted in no data*."
    But it can show every-level data when I used table view.
    It was so strange..
    Did anybody meet this before?
    Thanks in advance.
    regards,
    Anne

    Hi,
    Yes, I have the same problem with pivot table for hierarchy dimension.
    If you use a normal table (not pivot) it seem to work. Unfortunatley with restrictions as normal table view have.
    Same problem still exist in 11.1.1.6.5
    I have logged a SR to Oracle about this.

  • Hiding columns in pivot table OBIEE 11g

    Hi experts,
    I am trying to create a pivot table with individual values in columns but I also need to display a grand total as values but also as percentage and as cumulative percentage.
    I duplicated the measure once in the measure area, and selected display data as percentage of column, and another time using display cumulative and percentage of column.
    The result is fine, but all the elements are displayed as column for the percentage and for the cumulative. Or, I only need the Grand Total Percentage and Cumulative, but I don't need all the columns for Percentage and cumulative.
    I have tried to find out a way to customize the XML but nothing good.
    Is there a way to display only the grand total for percentage and cumulative without having to display all the individual columns?
    Any help highly appreciated.
    Regards

    If I get your question correctly.. You are trying to present the grand total towards the end of the Pivot and OBIEE is displaying the totals of all the sections and then the Grand Total.
    Try not to use the grand total of the sections but create a new pivot view and just display the grand total in that view.
    So you will have your normal sections and then another pivot view just for the grand total.
    As far as I know, there is no option to hide the individual section totals.

  • Why can't i change row and column height in tables?

    a mind-boggling problem to be sure. For some odd reason, I can't use the inspector to type in row/column heights for tables. I can use the up/down arrows, but those only work in increments of 1. I can manually adjust them one by one but as soon as I edit text in a different table cell, I have to start all over again. Does anyone else have this problem?

    Hi Gerry & Ric
    I had already tried both of your suggestions without any luck but I appreciate the help anyway. I should've been a bit more specific: I can actually type in the column/row height windows, but when I press return or tab, Pages ignores the numbers. I've tried using both the number pad and the regular keyboard numbers and every manner of clicking, enter, tab, control, alt......there must be some setting with my computer that is causing an incompatibility with Pages. Boh!
    Susie

  • Calculated column in pivot table

    How can I add a calculated column (Daily Average) in a pivot table like this?
    "Product" in row and "Date" in column and a "Daily Average" column to the right.
    Date1 Date2 Date3 +Grand Total       Daily Average+
    Product

    click right mouse on column you will get duplicate column
    in duplicate column propties you have option like aggreate avg apply it you will get result
    regards
    bethamsetty

Maybe you are looking for

  • Using Set Cursor Busy in Veristand Custom Device Page

    I am writing a Custom Device in Veristand and tried using the Set Busy vi to disable the cursor while I am doing some tasks on a System Explorer page.  It seems like the Set and Unset Busy vi do not work inside of the System Explorer environment.  I

  • IPhoto - Facebook Faces Problem

    I'm having issues with Facebook and iPhoto Faces integration.  Here is what is happening:  I go through my pictures in iPhoto and tag Faces.  Then I upload the pictures through iPhoto to Facebook.  But if I've tagged a Face of an individual in iPhoto

  • Regarding Generated Inspection Points

    Hi Gurus, I am doing in process inspection(Type 03) & using inspection points 150(Generated inspection points). In operation details i have maintained time related & given time factor as 1 hr.When i am releasing order inspection lot is generated but

  • About use mouse middle key to call JavaScript function question

    I want use mouse middle key to call JavaScript function (<a href="javascript:help()">) help() will open a new Window and direct to my GUI Help Page but when I click it with middle key ,it will open new Tab blank Page that url="javascript:help()"; can

  • My home page magnified in Firefox version 11. What do I do?

    I even tried uninstalling Firefox then re-installing it. That didn't work.