MDX Rank Over Partition

Are there any MDX gurus who can help me?
I am trying to produce an MDX query that generates a ranked result set, within this I am trying to get two levels of ranking based on Net Sales, firstly the ranking within the overall set, and secondly a ranking partitioned by an attribute dimension (the equivalent of RANK () OVER (PARTITION BY ...) in SQL Server), with the final result set sorted alphabetically by the attribute name and secondly by Net Sales. So far I have got the sorting and the overall ranking to work but not the partitioned rank. Any solution will need to be fast as the base dimension has 100K members.
My current MDX looks like this:
WITH
SET [Divisions] AS '[AttributeContract].[Att_CC01].Children'
SET [ContractsByDiv] AS
'GENERATE(
ORDER(
[AttributeContract].[Att_CC01].Children,
AttributeContract.CurrentMember.[MEMBER_NAME],
BASC
CROSSJOIN(
AttributeContract.CurrentMember
ORDER(
NonEmptySubset(
UDA([Entity].[Entity Contract Reporting], "Contract")
[Net Sales],
BDESC
MEMBER [Account].[Overall Rank] AS 'Rank([ContractsByDiv].CurrentTuple,[ContractsByDiv],[Net Sales])'
MEMBER [Account].[Rank In Div] AS '1'
SELECT
[Net Sales]
,[Overall Rank]
,[Rank In Div]
} ON COLUMNS,
[ContractsByDiv]
} ON ROWS
FROM HCREPRT2.Analysis
WHERE
[Year].[FY13],
[Period].[BegBalance],
[ISBN Type].[Total ISBN Type],
[Lifecycle].[Front List],
[Scenario].[DPG_Budget],
[Market].[Total Market],
[Version].[Working],
[Sales Channel].[Total Sales Channel]
Any suggestions as to how to do this or whether it is possible?
Regards,
Gavin
Edited by: GavinH on 07-Mar-2012 02:57

This was the solution I came up with:
The following query returns a result set with the the data ranked across the overall set and with a ranking partioned by division:
WITH
SET [Divisions] AS 'ORDER([AttributeContract].[Att_CC01].Children,AttributeContract.CurrentMember.[MEMBER_NAME],BASC)'
SET [EntitySet] AS 'ORDER(NonEmptySubset(UDA([Entity].[Entity Contract Reporting], "Contract")),[Net Sales],BDESC)'
SET [ContractsByDiv] AS
'GENERATE(
[Divisions],
CROSSJOIN(
AttributeContract.CurrentMember
NonEmptySubset([EntitySet])
-- Rank in whole data set
MEMBER [Account].[Overall Rank] AS 'Rank([ContractsByDiv].CurrentTuple,[ContractsByDiv],[Net Sales])'
-- Ranking in division
MEMBER [Account].[Rank In Div] AS
'Rank(
([AttributeContract].CurrentMember,[Entity].[Entity Contract Reporting].CurrentMember),
CROSSJOIN(
AttributeContract.CurrentMember
NonEmptySubset([EntitySet])
[Net Sales]
-- Rownumber
MEMBER [Account].[RowNumber] AS 'RANK([ContractsByDiv].CurrentTuple,[ContractsByDiv],1,ORDINALRANK)'
SELECT
[Net Sales]
,[Overall Rank]
,[Rank In Div]
,[RowNumber]
} ON COLUMNS,
[ContractsByDiv]
} ON ROWS
FROM HCREPRT2.Analysis
WHERE
[Year].[FY13],
[Period].[BegBalance],
[ISBN Type].[Total ISBN Type],
[Lifecycle].[Front List],
[Scenario].[DPG_Budget],
[Market].[Total Market],
[Version].[Working],
[Sales Channel].[Total Sales Channel]
The key was to use the cross join portion of the generate statement used to create the overall set as the set for the intra divisional ranking.

Similar Messages

  • Dear SQL-Experts:  RANK() OVER (...) - Function

    Hello,
    I'm looking for a solution for the following SQL-SELECT-Problem.
    Imagine a table or a view with
    many items with a composite key (5 columns)
    some item-specific data columns and...
    ...at least an integer-column which counts double or more entrys of items with the same key (call it U_EntryCnt)
    What I need is a SELECT-Statement which SELECTs all Items BUT only one of the double entrys (if there are doubles).
    It should SELECT only that one of the double entrys which has the maximum number of the double-entrys in the U_EntryCnt-column.
    My idea is to create a VIEW like (three key-columns in this example):
    SELECT
         RANK() OVER (PARTITION BY U_KeyCol1, U_KeyCol2, U_KeyCol3 ORDER BY U_EntryCnt DESC) AS Rank,
         U_KeyCol1, U_KeyCol2, U_KeyCol3,
         U_DatCol1, U_DatCol2,..........U_DatColN,
            U_EntryCnt
    FROM
         [@TST_EXAMPLE]
    And afterwards SELECTing FROM that VIEW WHERE Rank=1
    A test on a little example table seems to work. But could somebody tell me is this is the right way?
    Thanks,
    Roland
    PS.:
    GROUP BY does not work in my opinion. When I want to SELECT any column, this column must be added to the GROUP BY statement. Once a selected data col differs within the same key doubles I get two results of the same key and this is not wanted.

    Hi Robin,
    thanks for your answer. (I hope I've understand everything right - this problem also seems to lead me to the boundary of my english ;-/ )
    Within the double-key-rows the MAX-Aggregat gives me not the correct result: It does not return the data from the row with the MAX(U_EntryCnt) but rather the maximum of the data within the double-key-rows.
    The best would be an complete example.
    Here is the example-table with (unsorted) keys, data and the entry-counter (only one example DataCol for clearness):
    KeyCol1 |KeyCol2 |KeyCol3 |DataCol1     |EntryCnt
    ================================================
    A     |A     |1       |AA1 XXX     |1
    B     |B     |1       |BB1 Wanted     |2
    A     |A     |1       |AA1 Wanted     |2
    B     |B     |1       |BB1 XXX     |1
    C     |C     |1       |CC1 Wanted     |1
    The wanted rows are marked with "Wanted" in the Data colum for example. Technically they're wanted because these rows are containing the maximum EntryCnt-Number within their key-double rows.
    Robin:
    When you talk about sub-select I think you mean sth. like this:
    SELECT
         T0.U_KeyCol1, T0.U_KeyCol2, T0.U_KeyCol3, MAX(T0.U_EntryCnt),
         (SELECT T1.U_DatCol1
         FROM [@TST_EXAMPLE] T1
         WHERE
         T0.U_KeyCol1=T1.U_KeyCol1 AND
         T0.U_KeyCol2=T1.U_KeyCol2 AND
         T0.U_KeyCol3=T1.U_KeyCol3 AND
         T1.U_EntryCnt=MAX(T0.U_EntryCnt)) AS DatCol1,
         (SELECT T1.U_DatColN
         FROM [@TST_EXAMPLE] T1
         WHERE
         T0.U_KeyCol1=T1.U_KeyCol1 AND
         T0.U_KeyCol2=T1.U_KeyCol2 AND
         T0.U_KeyCol3=T1.U_KeyCol3 AND
         T1.U_EntryCnt=MAX(T0.U_EntryCnt)) AS DatColN
    FROM
         [@TST_EXAMPLE] T0
    GROUP BY
         T0.U_KeyCol1, T0.U_KeyCol2, T0.U_KeyCol3
    Yes: this also works.
    As far as I know every column needs it's own subSelect. Very extensive when we talk about 20 to 40 columns.
    If the RANK function really gives the same result under all circumstances (in this example it does) it's much easier:
    First create a VIEW which contains a Rank-column:
    CREATE VIEW [dbo].[@TST_EXAMPLE_VIEW] AS
    SELECT
         RANK() OVER (PARTITION BY U_KeyCol1, U_KeyCol2, U_KeyCol3 ORDER BY U_EntryCnt DESC) AS Rank,
         Code, Name,
         U_KeyCol1, U_KeyCol2, U_KeyCol3,
         U_DatCol1, U_DatCol2, U_DatCol3, U_DatCol4,
         U_EntryCnt
    FROM
         [@TST_EXAMPLE]
    And now the condition WHERE Rank=1 seems to give the wanted rows (in the example it does :-):
    SELECT * FROM [@TST_EXAMPLE_VIEW] WHERE Rank=1
    Because this is a much more clearly arranged query, it would be nice if somebody could confirm that this is also a right way.
    Another question is which of the two Query-examples may have the best SQL-Server performance (which ist faster)

  • Please explain ranking and partition?

    I'm familiar with basic SQL and PL/SQL.  I've encountered the following clause in a query, which I don't understand:
       SELECT...
                 T1.valueA,
                  T1.dateValue,
                 T1.valueB,
                T1.dateValue_2,
                 IsCurrent  
        FROM (SELECT
                decode(row_number() over (
                        partition by T1.valueA order by T1.dateValue asc), 1,DECODE(sign(T1.dateValue - sysdate),1,'N','Y'), 'N') as IsCurrent
                             ,  'N' as IsCancellable
                  ,dense_rank () over ( partition by T1.valueA  order by  T1.valueB desc, T1.dateValue desc, T1.dateValue_2 desc) as rank
          FROM T1    etc...

    Your query must be very old - pre case era - or ...
    I'd rather see something (at least IMHO) more readable, maybe
    select ...
           t1.valuea,
           t1.datevalue,
           t1.valueb,
           t1.datevalue_2,
           iscurrent 
      from (select case row_number() over (partition by t1.valuea order by t1.datevalue asc)
                        when 1
                        then case when t1.datevalue > sysdate
                                  then 'N'
                                  else 'Y'
                             end
                        else 'N'
                   end iscurrent,
                   'N' iscancellable,
                   dense_rank () over (partition by t1.valuea
                                           order by t1.valueb desc,t1.datevalue desc,t1.datevalue_2 desc
                                      ) rank
             from t1
    as a non native speaker I doubt I can beat the documentation (seems pretty good to me):
    Analytic Functions DENSE_RANK
    Regards
    Etbin

  • Qualify row_number over(Partition by col order by col) and char2hexint() functions in informatica

    How to implement qualify row_number over(Partition by col order by col) and char2hexint in informatica in a way that is supported by pdo?
    Apart from sql overriding or using stored procedure ,is there any other solution?Can rank transformation help here? ....But, I guess rank transformation cannot be pushed down..
    help please !

    Hi Saichand,
    The links were helpful. But i am not getting how it is working in test and not in live.
    I found one difference while deploying . The column names of the object both in Test and Production had spaces.For E.g: Full Name
    When this column Full Name is pulled to the repsository in test , it automatically put double quotes for the column names in the physical sql when it hits the database.
    But, In production , when I pulled the column the report gave error as Invalid Identifier since OBIEE generated column name as Full Name without double quotes.
    Then I changed the column in Phyiscal Layer repository by having double Quotes for all columns. Afte that report worked fine.
    Whether this has caused any issue in Row Partition.
    Is there any setting to have column name in Double Quotes ?
    Thanks,
    Johnny

  • Ranking over consecutive dates

    Hi guys,
    I have been struggling with this for some days already and I have tried to implement different solutions I was able to get from searching the internet, and applying some approeaches learned from this forum on similar questions, but maybe if I put que question here someone knows exactly the best way to handle it:
    So I have a table like this:
    with payments as
    select '1' as ID, '20130331' as DateR, 'Not_paid' as Status from dual
    union
    select '1' as ID, '20130430' as DateR, 'Paid' as Status from dual
    union
    select '1' as ID, '20130531' as DateR, 'Not_paid' as Status from dual
    union
    select '2' as ID, '20130331' as DateR, 'Not_paid' as Status from dual
    union
    select '2' as ID, '20130430' as DateR, 'Not_paid' as Status from dual
    union
    select '3' as ID, '20130331' as DateR, 'Paid' as Status from dual
    union
    select '3' as ID, '20130430' as DateR, 'Paid' as Status from dual
    union
    select '3' as ID, '20130531' as DateR, 'Paid' as Status from dual
    And I am trying to get the amount of the current consecutive non-payments from a user. Now, it starts to count everytime the previous payments was Paid or it´s the first payment.
    I have tried to get through dense rank, giving me this as output:
    select ID, dater, status, dense_rank() over (partition by ID, status order by dater asc) rnk from payments
    But I need to get something like this:
    ID DATER STATUS RNK
    1   20130331  Not_paid  1
    1   20130430  Paid  1
    1   20130531  Not_Paid  1
    2   20130331  Not_paid  1
    2   20130430  Not_paid  2
    3   20130331  Paid  1
    3   20130430  Paid  2
    3   20130531  Paid  3
    Such that if I want to get the max(rank) to check how many non-payments a user currently has I get that ID has 1 unpayment, ID 2 two consecutive unpayments, and ID 3 has 0 unpayments. This is because on the fourth consecutive non-payment I have to consider the user as churned.

    Hi,
    Here's one way:
    WITH got_grp_num AS
        SELECT  p.*
        ,      ROW_NUMBER () OVER ( PARTITION BY  id
                                    ORDER BY      dater
             - ROW_NUMBER () OVER ( PARTITION BY  id, status
                                    ORDER BY      dater
                                  )   AS grp_num
        FROM    payments  p
    SELECT    id, dater, status
    ,         ROW_NUMBER () OVER ( PARTITION BY  id, status, grp_num
                                   ORDER BY      dater
                                 )   AS rnk
    FROM      got_grp_num
    ORDER BY  id, dater
    For an explanation of the Fixed Difference technique used here, see
    https://forums.oracle.com/forums/thread.jspa?threadID=2302781 and/or
    https://forums.oracle.com/forums/thread.jspa?threadID=2303591
    By the way, storing date information in a sting column is simply asking for trouble.  Use a DATE column instead.

  • Case Statement in Analytic Function SUM(n) OVER(PARTITION BY x)

    Hi Guys,
    I have the following SQL that doesn't seem to consider the When clause I am using in the case staement inside the analytic function(SUM). Could somebody let me know why? and suggest the solution?
    Select SUM(Case When (A.Flag = 'B' and B.Status != 'C') Then (NVL(A.Amount_Cr, 0) - (NVL(A.Amount_Dr,0))) Else 0 End) OVER (PARTITION BY A.Period_Year) Annual_amount
         , A.period_year
         , B.status
    , A.Flag
    from A, B, C
    where A.period_year = 2006
    and C.Account = '301010'
    --and B.STATUS != 'C'
    --and A.Flag = 'B'
    and A.Col_x = B.Col_x
    and A.Col_y = C.Col_y
    When I use this SQL, I get
    Annual_Amount Period_Year Status Flag
    5721017.5 --------- 2006 ---------- C -------- B
    5721017.5 --------- 2006 ---------- O -------- B
    5721017.5 --------- 2006 ---------- NULL ----- A
    And when I put the conditions in the where clause, I get
    Annual_Amount Period_Year Status Flag
    5721017.5 ---------- 2006 ---------- O -------- B

    Here are some scripts,
    create table testtable1 ( ColxID number(10), ColyID number(10) , Periodname varchar2(15), Flag varchar2(1), Periodyear number(15), debit number, credit number)
    insert into testtable1 values(1, 1000, 'JAN-06', 'A', 2006, 7555523.71, 7647668)
    insert into testtable1 values(2, 1001, 'FEB-06', 'B', 2006, 112710, 156047)
    insert into testtable1 values(3, 1002, 'MAR-06', 'A', 2006, 200.57, 22376.43)
    insert into testtable1 values(4, 1003, 'APR-06', 'B', 2006, 0, 53846)
    insert into testtable1 values(5, 1004, 'MAY-06', 'A', 2006, 6349227.19, 6650278.03)
    create table testtable2 ( ColxID number(10), Account number(10))
    insert into testtable2 values(1, 300100)
    insert into testtable2 values(2, 300200)
    insert into testtable2 values(3, 300300)
    insert into testtable2 values(4, 300400)
    insert into testtable2 values(5, 300500)
    create table apps.testtable3 ( ColyID number(10), Status varchar2(1))
    insert into testtable3 values(1000, 'C')
    insert into testtable3 values(1001, 'O')
    insert into testtable3 values(1002, 'C')
    My SQL:
    select t1.periodyear
         , SUM(Case When (t1.Flag = 'B' and t3.Status != 'C') Then (NVL(t1.credit, 0) - (NVL(t1.debit,0))) Else 0 End) OVER (PARTITION BY t1.PeriodYear)
         Annual_amount
         , t1.flag
         , t3.status
         , t2.account
    from testtable1 t1, testtable2 t2, testtable3 t3
    where t1.colxid = t2.colxid
    and t1.colyid = t3.colyid(+)
    --and t1.Flag = 'B' and t3.Status != 'C'
    Result:
    PeriodYear ----- AnnualAmount ----- Flag ----- Status ----- Account
    2006 ------------------ 43337 --------------- A ----------- C ---------- 300100
    2006 ------------------ 43337 --------------- B ----------- O ---------- 300200
    2006 ------------------ 43337 --------------- A ----------- C ---------- 300300
    2006 ------------------ 43337 --------------- B ------------ ----------- 300400
    2006 ------------------ 43337 --------------- A ------------ ----------- 300500
    With condition "t1.Flag = 'B' and t3.Status != 'C'" in where clause instead of in Case statement, Result is (which is desired)
    PeriodYear ----- AnnualAmount ----- Flag ----- Status ----- Account
    2006 ------------------ 43337 --------------- B ----------- O ---------- 300200

  • How to use to use rank over() function in block coding

    Hi,
    I am having problem with using rank () over function in block coding. I can't use it in declaration section with select statement.
    How to use in executable section of pl sql ?
    --Sujan                                                                                                                                                                                                                                                                                                                                                                                                           

    thanks

  • How to use rank() over(...) in a map?

    I use rank() over(...) in a Filter operator
    validate give a error: ora-30483

    Currently OWB does not directly support analytical functions. The (not very elegant) workaround could be implementing these feature in custom transformations.
    Regards:
    Igor

  • Analytical function SUM() OVER (PARTITION BY ) in Crosstab

    I am trying to resolve this from a very long time. I have an amount column that has to be grouped on Year, but all the other columns grouped by month. I am trying to achieve this using analytic function SUM(Case when (Condition1 and Condition2) then Sum(Amount) else 0 end) OVER ( PARTITION BY Account, Year), Where Account, Sub Account are the left axis columns. Now, column displays the values correctly, but at different rows. This is confusing.............
    For Ex: For Account 00001, there are 3 sub accounts 1000,2000,3000. For Sub account 3000, conditions 1 and 2 are satisfied, so it should display the Amount in the row corresponding to Sub account 3000, and 0 for remaining Sub Accounts. And the Total amount of all the sub accounts, which will be the same as amount for SubAccount 3000 should be displayed in the row corresponding to Account 00001.
    But I get blank rows for 1000 and 3000 Sub accounts and Amount displayed in 2000 Sub account, and blank for Account 00001 also.
    When I created the same workbook in Tabular form, the same amount is displayed for all the SubAccounts of a single Account.
    When I used this CASE statement in TOAD, I figured that this is due to the Analytic function. When I use a group by clause as shown below instead of partition by, I get the results I need.
    SELECT (Case when (Condition1 and Condition2) then Sum(Amount) else 0 end), Account, Sub Account FROM tables WHERE conditions GROUP BY Year, Account, Sub Account
    But I cannot use groupby for whole SQL of the workbook as I need the other columns with page item 'MONTH' not 'Year'.
    Could somebody please help me with this?

    Hi,
    In your tabular form do you get the correct total display against all you subaccounts and account? If this correct then you can use case to ensure that the total is displayed only for the single account.
    Once you have the correct totals working in a tabular form it is easier to re-produce what you want in a cross-tab.
    Rod West

  • Over Partition by in OWB 9i

    Hi,
    I am using OWB V9i. I need to implement an sql statement in a mapping.The statement is
    CASE WHEN (tr_dt=lead(tr_dt) OVER(PARTITION BY ID ORDER BY ID,tr_dt))
    THEN lead(ef_dt) OVER(PARTITION BY ID ORDER BY ID,tr_dt)
    ELSE tr_dt
    END
    I am not able to put the case statement in an expression as it has OVER PARTITION BY which the expression operator is not accepting. Is there any way i can implement the same in the mapping without using a table function or any other procedure???
    Regards
    Bharath

    OWB's support for analytics has always been pretty sparse. They did release a doc that showed a way to build some analytics using various workarounds here:
    http://www.oracle.com/technology/sample_code/products/warehouse/files/analyticfunctions.pdf
    However my approach has always been to tend towards simplicity. A convoluted "workaround"mapping is harder to tune, troubleshoot, or maintain, and I always worry about how OWB will handle such workarounds over subsequent release upgrades. So, for anything not clearly natively supported by OWB - I build a view with the analytic and use that as my source.
    Mike

  • Group by and over partition.

    Hi to everybody....
    i ahev a table like this:
    id name salary
    1 John 1000
    2 Tom 1300
    3 Alan 1400
    4 Mark 1800
    and i do a query like this:
    select max(salary) from table
    and i have 1800
    What i would like to have, is a query that return me the id, the name and the max salary.
    i can do
    select * from
    select max(salary) as max from table) AAA,
    table
    where AAA.max =table.salary.
    But i would like to do it in only one query using the group by expression and over partition statement.
    Thank's in advance to everybody!

    Flavio,
    You can use...
    sql> select max(sal) from emp;
      MAX(SAL)
          5000
    sql> select empno, ename, max(sal) over () from emp;
         EMPNO ENAME      MAX(SAL)OVER()
          7369 SMITH                5000
          7499 ALLEN                5000
          7521 WARD                 5000
          7566 JONES                5000
          7654 MARTIN               5000
          7698 BLAKE                5000
          7782 CLARK                5000
          7788 SCOTT                5000
          7839 KING                 5000
          7844 TURNER               5000
          7876 ADAMS                5000
         EMPNO ENAME      MAX(SAL)OVER()
          7900 JAMES                5000
          7902 FORD                 5000
          7934 MILLER               5000If you need to have the max per department , you just would need to add....
      1* select empno, ename, max(sal) over (partition by deptno) from emp
    sql> /
         EMPNO ENAME      MAX(SAL)OVER(PARTITIONBYDEPTNO)
          7782 CLARK                                 5000
          7839 KING                                  5000
          7934 MILLER                                5000
          7566 JONES                                 3000
          7902 FORD                                  3000
          7876 ADAMS                                 3000
          7369 SMITH                                 3000
          7788 SCOTT                                 3000
          7521 WARD                                  2850
          7844 TURNER                                2850
          7499 ALLEN                                 2850
         EMPNO ENAME      MAX(SAL)OVER(PARTITIONBYDEPTNO)
          7900 JAMES                                 2850
          7698 BLAKE                                 2850
          7654 MARTIN                                2850HTH,
    Rajesh.

  • Issue with ROW_NUMBER() OVER (PARTITION)

    Hi,
    Please read the Thread completely, I have created a Report to see Yearly Turnover%, The report works fine but when I take Quarter and Months in it, it restricts the result to only 1 line(i.e., my first year's Turnover) and when I opened the Physical query, I saw the BI Server is using
    ROW_NUMBER() OVER (PARTITION BY)
    which is not at all necessary.
    *I tried disabling WITH_CLAUSE_SUPPORTED and PERF_PREFER_MINIMAL_WITH_USAGE but didn't get any resolution, Could anybody help me out?
    thanks in Advance,
    Anand

    You said 'it restricts the result to only 1 line' means the value is nor drill down to next level?
    In that case Yearly Turnover% is set to Year level?

  • Need help converting SQL "OVER (PARTITION BY   )" to JPQL equivalent - JPA

    Having trouble converting this query:
    select
    sdi,
    val,
    vldtn,
    TO_CHAR(sdt, 'yyyy-mm-dd hh:mi:ss AM')
    from
    select
    sdi,
    val,
    vldtn,
    sdt,
    max(sdt) over (partition by sdi) as MaxDate1
    from
    r_ins
    ) x
    where x.sdt = x.MaxDate1
    and sdi in (1234,2345,3456,4567,5678,6789,7890);
    to JPQL equivalent using JPA
    Able to convert simple queries but I do not know how to handle the "over (partition by sdi)" portion of the query.
    Can anyone help
    TIA
    Jer

    Paul Horth wrote:
    Why have the power (and cost) of Oracle and then not use those powerful features because you are restricting yourself to a vanilla set of SQL because you are using some generic framework.You know how it is :
    1 - Application developers create code & queries but only test them on tiny database with low volume and no concurrency at all.
    2 - Application goes Live, Database grows (as expected) but stupid optimizer is not as fast as on test environment (that was mostly empty)
    3 - Queries are now 200 times slower.
    4 - Expensive DB expert comes and gathers statistics, creates indexes, rewrites queries, uses hint/outline/SQLprofile.
    Conclusion : Database is evil and prevent application from working efficiently, the proof of all that being : nothing had to be done on application's side to make things work correctly. Database is declared guilty.
    Which could translate to :
    1 - Team buy a formula one with 800HP that can reach 200mph in less than 10 seconds.
    2 - Give it a pilot that doesn't even want to understand what-the-heck is a gearbox/transmission. Pilot only drives in 1st gear.
    3 - The formula one is now doing 0.003 miles per gallon, doing the hell of a noise, and is limited to 80mph +(any $10000 family wagon is faster in average)+
    4 - Expensive expert comes and check everything in the formula one. Finally understand the problem and modify the gearbox to a sloppy automatic transmission
    Conclusion : Formula 1 is evil and prevent pilot from being fast. The proof of that being : nothing had to be changed on pilot's side to make things work correctly. Formula 1 is declared guilty.
    You cannot win race without understanding how the car/engine/transmission/physics/race rules work.
    Too much levels of abstraction is bad. Treating the database as a black box is the most seen "Bad Idea" these days (to my point of view).
    Warning: I am biased towards Oracle :-)And so am I.
    (^_^)

  • No possible debug for mapping containing "rank() over"

    It looks like mappings using "rank() over" functions (most of mines) are no candidate for debug functionalities :-/
    Analyzing map for debug...
    Retrieving runtime connection info...
    Connecting to runtime schema...
    Checking character set of runtime schema...
    Configuring sources and targets...
    Analyzing map for debug...
    Configuring sources and targets...
    Validating map...
    Correlated Commit is OFF.
    Generating debug package...
    Deploying temp debug tables...
    Deploying debug package...
    Debug code deployment messages:
    LINE 5964 ,COLUMN 66:
    PLS-00103: Encountered the symbol "OVER" when expecting one of the following:
    . ( * % & = - + ; < / > at in is mod not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between ||
    End debug code deployment messages
    DBG1012: Debug deployment errors, can't run debug code.

    That's right.
    Though, use of dedup is totally prohibitive to nest rank() function (in order to use it in the outer where clause) and creation of dumb tables are messy in a way.
    I chose creating a dumb constant vector that matches the rest of the query, filtering it to an empty set and then UNION ALL with the main query that is thenafter filtered on rank column (and it works pretty fine)
    ...just a pity it can't be debugged (they are my most complex mappings) with the debugger

  • Issue with  OBIEE ROW_NUMBER() OVER (PARTITION BY)

    Hi All,
    I am facing some issue with the ROW_NUMBER() OVER (PARTITION BY function in the query that is being generated. I am currently on version 11.1.1.6. I have 1 FACT and 1 Dimension table. Within the dimension I have create a level based hierarchy namely REGION -> GROUP - DIVISION etc. Now the problem is that the OBIEE automatically applies *"ROW_NUMBER() OVER (PARTITION BY T9.PRODUCT_TYPE_DESC, T130.DIVISION_DESC, T130.REGION_DESC ORDER BY T9.PRODUCT_TYPE_DESC ASC, T130.DIVISION_DESC ASC, T130.REGION_DESC ASC) "
    to the query where in it is not required at it returns with 3 different row numbers. If i remove this line and the where clause I am able to get correct results however its not working whatever I do in the RPD. Please advise.
    WITH
    SAWITH0 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6
    from
    (select sum(T157.PL_GRAND_TOTAL) as c1,
    sum(T157.TRANSACTION_AMT) as c2,
    T130.DIVISION_DESC as c3,
    T130.REGION_DESC as c4,
    T130.GROUP_DESC as c5,
    T9.PRODUCT_TYPE_DESC as c6,
    ROW_NUMBER() OVER (PARTITION BY T9.PRODUCT_TYPE_DESC, T130.DIVISION_DESC, T130.REGION_DESC ORDER BY T9.PRODUCT_TYPE_DESC ASC, T130.DIVISION_DESC ASC, T130.REGION_DESC ASC) as c7
    from
    DIM_ALL_MODULES_REF T9,
    DIM_MIS_TREE_REF T130,
    DIM_DATE_SERIES T123,
    FCT_ALL_MODULES_TRANS T157
    where ( T9.SGK_MIS_ID = T130.SGK_MIS_ID and T9.SGK_MODULE_ID = T157.SGK_MODULE_ID and T123.SGK_TIME_ID = T157.SGK_TIME_ID and T123.TRANS_DATE between TO_DATE('2011-01-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2011-03-31 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') )
    group by T9.PRODUCT_TYPE_DESC, T130.DIVISION_DESC, T130.GROUP_DESC, T130.REGION_DESC
    ) D1
    where ( D1.c7 = 1 ) ),
    SACOMMON42934 AS (select T130.DIVISION_DESC as c2,
    T130.REGION_DESC as c3,
    T130.GROUP_DESC as c4,
    T9.PRODUCT_TYPE_DESC as c5,
    sum(T258.BEG_NMK_EQ_COST_AMT) as c6,
    T123.TRANS_DATE as c7,
    sum(T258.END_NMK_EQ_COST_AMT) as c8
    from
    DIM_ALL_MODULES_REF T9,
    DIM_MIS_TREE_REF T130,
    DIM_DATE_SERIES T123,
    FCT_MODULES_BEG_END_BAL T258
    where ( T123.SGK_TIME_ID = T258.SGK_TIME_ID and T9.SGK_MIS_ID = T130.SGK_MIS_ID and T9.SGK_MODULE_ID = T258.SGK_MODULE_ID and T258.PRODUCT_TYPE_ID = 2 and T123.TRANS_DATE between TO_DATE('2011-01-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2011-03-31 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') )
    group by T9.PRODUCT_TYPE_DESC, T123.TRANS_DATE, T130.DIVISION_DESC, T130.GROUP_DESC, T130.REGION_DESC),

    Hi Dhar,
    Thanks for replying back. But the ROW_NUMBER thing is inserted with the "WITH SUPPORTED" clause only but that is something which are the default settings. However, I notice that ROW_NUMBER() OVER (PARTITION BY) lines are erratic and are not consistent. So sometimes the drill works properly when no ROW_NUMBER() OVER (PARTITION BY) is generated but other times data is wrong. I am not sure why this behaviour is erratic even though I select the same values.
    This is surely a product problem as the condition where c7 = 1 filters the result and does not take into account all values.
    Even when I do not use WITH_SUPPORTED clause the stitch does not happen properly. Please advice if this is ever going to be by Oracle or any work around for this?
    Thanks

Maybe you are looking for