Analytical functions, model indexes and multiple dimensions.

I don't understand the notion of analytic functions (windowing clause) in the regulation of a model clause. I discovered an ordinary table as one-dimensional, and I can understand the concept of window, just like a line on a segment line. However with the models, there are several dimensions, so I guess that the window to become a kind of cube, instead of a line segment. But I'm not.

For example, I have a matrix sparse 2D, with 5 values non-zero:
select * from field
  where f is not null

X     Y     F
-----------------
5     8     X
6     6     X
6     8     X
7     7     X
7     8     X
I guess that the following clause of the model
with t as(
  select *
    from field
   model
     reference old_field
       on
       (
         select * from field
       )
       dimension by (x, y)
       measures     (f)
     main new_field
       dimension by (x, y)
       measures     (cast(f as varchar2(3)) f)
       rules
       (
         f[x,y] = max(old_field.f) over (order by old_field.y range between 1 preceding and 1 following)
       ))
select * from t
  where f is not null
to assign for each cell up among its neighbors vertical 2. Just like
0 0 0      0 X 0
0 X 0  ->  X X 0
X 0 0      X X 0
But the real result is all NULL values.

Hello

with a as
(
select
level L
from
dual
connect by level < 4
)

select
     X
     ,Y
     ,Z
     ,X*3+Y

from
     a          A1
     ,A     A2

model
     dimension by ( A1.L X, A2.L Y )
     MEASURES (0 Z)
     RULES
     (
     Z[X,Y] = COUNT(Z) OVER (ORDER BY X * 3 + Y RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)
     )

X Y Z X*3+Y
- - - -----
1 1 2     4
1 2 3     5
1 3 3     6
2 1 3     7
2 2 3     8
2 3 3     9
3 1 3    10
3 2 3    11
3 3 2    12 

 9 rows selected 

for x, y = 1.1, there is no previous rank if it is not counted. current line + line = 2
for x, y = 1, 2, the previous line + line current + more rank = 3
for x, y = 1.3 the previous line + line current + more rank = 3
for x, y = 2, 1, the previous line + line current + more rank = 3
...
for x, y = 3, 2 the previous line + line current + more rank = 3
for x, y = 3, 3 the stored previous + current line = 2. There is no next line.

What exectly not understand you?

Kind regards
Peter

Tags: Database

Similar Questions

  • Need help with the analytical function select maximum and minimum of the results of the column

    Hey there OTN.

    I have an interesting application that I was hoping you would be able to help me with. I have a requirement to conditionally select the max and min of a column in bi-editor and since my editor works from an OBIEE analysis, I need store MAX and MIN of the column values in separate columns to match with. See the example below. You will notice that there are 4 stores including today's sales. I must have OBIEE through all the results of the column for sales, then choose the max of the dataset object. I can't use MAX here because he will choose the MAX of the line which will return only sales of this line. Instead, one must analyze all sales results and choose the appropriate column. Any idea on how to do this in OBIEE/publisher? Or is this not possible.

    Day Store Sales Sales of MAX Sales MIN
    05/11/15Store 1500080001000
    05/11/15Store 2750080001000
    05/11/15Store 3100080001000
    05/11/15Store 4800080001000

    I'm waiting for your answers. Thanks in advance!

    PS: I will always mark messages that are useful and eventually mark it as correct answer if we come to a resolution!

    See you soon.

    You can't do the same thing with RANK ("dirty")?

    Rank ("dirty") = 1: the max value in the result of sales

    RANK (-1 * "Sales") = 1: the min in the result of sales value

    I guess you can and then format the cells based on these values, where a value of 1 is the max or min according to the RANKING formula you used...

  • Nth salary using the analytic function

    I use under function to calculate second highest with empno and deptno salary.

    Is it possible to get the same result with another query without using Assembly only analytical functions condition.using and windows function is possible to get the desired output?

    SELECT e.empno,

    e.DEPTNO,

    tmp. SAL as second_higher_salary

    FROM emp e,.

    (SELECT Empno,

    DEPTNO,

    SAL,

    DENSE_RANK() (PARTITION BY deptno ORDER of sal) AS rnk

    WCP

    ) tmp

    WHERE tmp.deptno = e.deptno

    and tmp.rnk = 2

    EMPNO DEPTNO SAL

    ---------- ---------- ----------

    7934 10 2450

    7782 10 2450

    7839 10 2450

    7876 20 1100

    7369 20 1100

    7902 20 1100

    7788 20 1100

    7566 20 1100

    7900 30 1250

    7844 30 1250

    7654 30 1250

    7521 30 1250

    7499 30 1250

    7698 30 1250

    7900 30 1250

    7844 30 1250

    7654 30 1250

    7521 30 1250

    7499 30 1250

    7698 30 1250

    Here's my solution:

    Select empno,

    DEPTNO,

    FIRST_VALUE (sal) (PARTITION BY deptno ORDER by sal desc)

    de)

    SELECT EmpNo,

    DEPTNO,

    Decode (DENSE_RANK () OVER (PARTITION BY deptno order by sal desc), 1,-sal, sal) sal

    WCP

    )

    /

    EMPNO DEPTNO FIRST_VALUE (SAL) OVER (PARTITIONBYDEPTNOORDERBYSALDESC)

    ---------- ---------- -----------------------------------------------------

      7782 10 2450
      7934 10 2450
      7839 10 2450
      7566 20 2975
      7876 20 2975
      7369 20 2975
      7788 20 2975
      7902 20 2975
      7499 30 1600
      7844 30 1600
      7654 30 1600
      7521 30 1600
      7900 30 1600
      7698 30 1600
  • Function index and virtual columns

    I just read the documentation of Oracle on the FBI. In the context of optimization with a function-based index, it is said that "a virtual column is useful for speed of access to data from expressions.". Here is the link Index-Organized Tables and indexes.

    My question is, does Oracle already not create a virtual column when we create a function-based index?

    Concerning

    Charlie

    Hi Charlie
    Yes, the database engine creates a virtual column. But this column is hidden. Reproduced in 11.2.0.3 example:
    SQL> CREATE TABLE t (n NUMBER);SQL> CREATE INDEX i ON t (round(n,0));
    SQL> SELECT column_name, hidden_column, virtual_column  2  FROM user_tab_cols
      3  WHERE table_name = 'T';
    
    COLUMN_NAME                    HIDDEN VIR
    ------------------------------ ------ ---
    N                              NO    NO
    SYS_NC00002$                  YES    YES
    

    HTH

    Chris Antognini

    Troubleshooting performance Oracle, Apress 2008/2014

  • Models to define templates for keys, indexes and constraints in Version 4

    Oracle SQL Developer Data Model Version 4.0.0.833

    Someone tell me where to find templates to define templates for keys, indexes and constraints?

    In version 3, it has been in tools > General Options > naming standards > models

    Hello

    In the 4.0.0.833 version, you must open the Properties dialog box for the design (by doing a right click on the entry for the relevant design in the browser tree, and select properties).

    Then in the design properties dialog box, select settings > naming Standard > models

    David

  • Function Index and Query Rewrite

    Hi members,


    I just stumbled on something that I've never thought of before.

    It has to do with the function according to index and (possibly re - write query)

    Here is my configuration:
    SQL> create table tab1 (
      2    x   varchar2 (1)   default 'N' not null check (x in ('Y', 'N')),
      3    y   varchar2 (100) not null
      4  );
    
    Table created.
    
    SQL> create index tab1ix on tab1 (NULLIF(x,'N'));
    
    Index created.
    
    SQL> insert into tab1 (y)
      2    (select rpad (level,100,'x') from dual connect by level <= 1000);
    
    1000 rows created.
    
    SQL> insert into tab1 (x,y) values ('Y', 'Hello there');
    
    1 row created.
    
    SQL> commit
      2  /
    
    Commit complete.
    
    SQL> exec dbms_stats.gather_table_stats(user, 'tab1', cascade => true)
    
    PL/SQL procedure successfully completed.
    So, I created a small table with a FBI.

    Now, let's use it.
    The first is a query that obviously do not use it.
    Second, one is a query that corresponds to the FBI.
    SQL> explain plan
      2     set statement_id = 'st1'
      3     into plan_table
      4  for
      5  select * from tab1 where x = 'Y';
    
    Explained.
    
    SQL> 
    SQL> select plan_table_output
      2    from table(dbms_xplan.display('PLAN_TABLE', 'st1','TYPICAL'));
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    
    ----------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost  |
    ----------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |   501 | 51603 |     5 |
    |   1 |  TABLE ACCESS FULL| TAB1 |   501 | 51603 |     5 |
    ----------------------------------------------------------
    
    
    SQL> explain plan
      2     set statement_id = 'st2'
      3     into plan_table
      4  for
      5  select * from tab1 where NULLIF(x,'N') = 'Y';
    
    Explained.
    
    SQL> 
    SQL> select plan_table_output
      2    from table(dbms_xplan.display('PLAN_TABLE', 'st2','TYPICAL'));
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    
    ----------------------------------------------------------------------
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost  |
    ----------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |        |     1 |   103 |     1 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| TAB1   |     1 |   103 |     1 |
    |   2 |   INDEX RANGE SCAN          | TAB1IX |     1 |       |     1 |
    ----------------------------------------------------------------------
    
    SQL> 
    No worries, right?
    Everything works as expected, when my predicate corresponds to the FBI, the index is used.


    But here's what surprises me. It seems that the index expression is rewritten then it is created:
    SQL> select column_expression from user_ind_expressions
      2  where index_name = 'TAB1IX';
    
    COLUMN_EXPRESSION
    --------------------------------------------------------------------------------
    CASE "X" WHEN 'N' THEN NULL ELSE "X" END
    
    SQL>
    Questions are now, is this safe? -Does still work?

    Can I trust the optimizer always did a rewrite such as performed when the index was created?


    This index might live throughout the years and many versions of the optimizer. But the expression stays (I guess)

    This is going into production this weekend, so I wanted to hear,
    ideas / comments?


    Best regards
    Peter
    SQL> select *from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for Linux: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    PS: NULLIF is nothing else than a syntactic sugar for the CASE expression equivalent?
    docs say:
    The NULLIF function is logically equivalent to the following CASE expression:

    CASE WHEN expr1 = END expr1 expr2 THEN NULL ELSE
    edited by: Peter on February 9, 2012 05:32

    Hi Peter

    In the docs for NULLIF, he said

    The NULLIF function is logically equivalent to the following CASE expression:

    CASE WHEN expr1 = expr THEN ELSE NULL expr1 END 2

    http://docs.Oracle.com/CD/B10501_01/server.920/a96540/functions85a.htm
    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions102.htm
    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions116.htm

    Which would explain the behavior you saw. As you pointed out, it is possible that the transformation of NULLIF expression BOX equivalent is likely to change? It seems unlikely - indeed, it seems to be an alias or a macro for the instruction box unless there is some way technically superior to implement this logic, it seems to be here to stay. Certainly, it has remained unchanged since the 9i.

    Not sure how that helps.

    David

  • analytical function and the aggregate function

    What are the analytical function and the aggregate function. What is the difference between them?

    Hello

    Analytic Functions : -.

    Analytical functions calculate a value of aggregation based on a group of lines. They differ from aggregate functions because they return several rows for each group. The Group of rows is called a window and is defined by the analytic_clause. For each line, a sliding window of lines is defined. The window determines the range of lines used for the calculations for the current line. Window sizes can be based on a physical number of rows or a logic as the time interval.
    Analytical functions are the last set of operations performed in a query with the exception of the last ORDER BY clause. Every joint and every WHERE, GROUP BY and HAVING clauses are met before the analytical functions are handled. As a result, analytic functions can only appear in the select list or the ORDER BY clause.
    Analytical functions are commonly used to calculate cumulative aggregates, moving, centered and considered.

    Aggregate functions : -.

    Aggregate functions return a line of single result based on the groups of lines, rather than on the unique lines. Aggregate functions can appear in selection lists, as well as in the HAVING and ORDER BY clauses. They are commonly used with the GROUP BY clause in a SELECT statement, where Oracle Database splits the rows in a table when asked or seen in groups. In a query that contains a GROUP BY clause, the select list items can be aggregation functions, GROUP BY constant expressions or expressions involving one of them. Oracle applies the functions of aggregation for each group of rows and returns a single result for each group line.
    If you omit the GROUP BY clause, Oracle then applies any aggregate functions in the select list for all rows in the table queried or the view. You use aggregate functions in the HAVING clause to eliminate groups of the output based on the results of aggregate functions, rather than the values of the individual lines of the queried table or view.

    Let me know if you feel any problem understanding.
    Thank you.

    Published by: varun4dba on January 27, 2011 15:32

  • FIRST_VALUE() and LAST_VALUE Analytic Functions

    Hi all

    May be that it is a fundamental issue. But I'm having a hard time understanding the difference between FIRST_VALUE() and LAST_VALUE() of analytical functions.

    As much as what I read the FIRST_VALUE function picks up the first record after the partition and order by and he returned after all calculation. And the LAST_VALUE does the opposite. But the result of the second query as I expected, are not (last value of the partition). It would be useful that someone could throw some light on it.
    select empno
         , ename
         , sal
         , first_value(ename) over(order by sal desc)
      from emp;
    
    empno  ename      sal       first_value 
    ------ ---------- --------- ----------- 
    7839   KING       5000.00   KING        
    7902   FORD       3000.00   KING        
    7788   SCOTT      3000.00   KING        
    7566   JONES      2975.00   KING        
    7698   BLAKE      2850.00   KING        
    7782   CLARK      2450.00   KING        
    7499   ALLEN      1600.00   KING        
    7844   TURNER     1500.00   KING        
    7934   MILLER     1300.00   KING        
    7654   MARTIN     1250.00   KING        
    7521   WARD       1250.00   KING        
    7876   ADAMS      1100.00   KING        
    7900   JAMES      950.00    KING        
    7369   SMITH      800.00    KING        
    
    14 Row(s) affected
    select empno
         , ename
         , sal
         , last_value(ename) over(order by sal desc)
      from emp;
    
    empno  ename      sal       last_value 
    ------ ---------- --------- ---------- 
    7839   KING       5000.00   KING       
    7902   FORD       3000.00   SCOTT      
    7788   SCOTT      3000.00   SCOTT      
    7566   JONES      2975.00   JONES      
    7698   BLAKE      2850.00   BLAKE      
    7782   CLARK      2450.00   CLARK      
    7499   ALLEN      1600.00   ALLEN      
    7844   TURNER     1500.00   TURNER     
    7934   MILLER     1300.00   MILLER     
    7521   WARD       1250.00   MARTIN     
    7654   MARTIN     1250.00   MARTIN     
    7876   ADAMS      1100.00   ADAMS      
    7900   JAMES      950.00    JAMES      
    7369   SMITH      800.00    SMITH      
    
    14 Row(s) affected
    Thank you
    Vincent

    Hey, Vincent,.

    When you use an analytic function with an ORDER BY clause, the results will be based on a window, which is a subset of the partition.
    If you do not specify a window (using the keywords LINE or LINES) the window everything will be in order by the ORDER BY clause, until and including the current line, including links.

    For example, in your second query:

    select empno
         , ename
         , sal
         , last_value(ename) over(order by sal desc)
      from emp;
    
    empno  ename      sal       last_value
    ------ ---------- --------- ----------
    7839   KING       5000.00   KING
    7902   FORD       3000.00   SCOTT
    7788   SCOTT      3000.00   SCOTT
    7566   JONES      2975.00   JONES
    7698   BLAKE      2850.00   BLAKE
    7782   CLARK      2450.00   CLARK
    7499   ALLEN      1600.00   ALLEN
    7844   TURNER     1500.00   TURNER
    7934   MILLER     1300.00   MILLER
    7521   WARD       1250.00   MARTIN
    7654   MARTIN     1250.00   MARTIN
    7876   ADAMS      1100.00   ADAMS
    7900   JAMES      950.00    JAMES
    7369   SMITH      800.00    SMITH    
    

    The analytic function

    last_value(ename) over(order by sal desc)
    

    Returns the last ename, not of the entire table, but the window starting with the highest sal (since you say "ORDER BY sal DESC") and including the current line and all the other lines that have the same sal.

    So consider the 1st row, ename = 'KING '. It has the most sal, so that a single line in the window, 'KING' IS THE LAST VALUE WINDOW.

    Now consider the 2nd row, where ename = 'FORD' and sal = 3000. The window includes now everybody with a sal of 3000 and more, which means the 3 rows 'KING', 'FORD' and 'SCOTT '. The last of them (in descending order of sal) is 'SCOTT '. (In fact, there is a tie, you could just as well say that "JONES" is changed, because there is a tie between the two rows where sal = 3000) When this happens, one of the lines will arbitrarily designate the "last" line don't expect not to be always the same line.)

    Because of this, LAST_VALUE is alwmost always used with an explicit windowing clause, beginning with the BEACH or LINES.

    If you want a request as your first request, but it contains the name of the lowest paid employee (that is, he always says 'SMITH' in the last column instead of 'KING'), then use FIRST_VALUE, but reverse the sort order:

    first_value(ename) over(order by sal ASC)
    
  • Indexing and the integrity constraint functionality difference

    Hello

    Sometimes I confuse me, how we can distinguish between indexing and the integrity of the features of constraint. Please let me know or if any available doc.


    Kind regards
    REDA

    I assume you mean unique vs unique index constraints?

    The sole (or Primary Key) constraints provide additional metadata that can be used by the optimizer.
    An index will be used to help the database to apply the constraint (it is created, or if there is it will be "captured" by coercion)

    Insofar as a document [url http://docs.oracle.com/cd/E11882_01/server.112/e25789/toc.htm] that's something, you should read

  • Is it possible to make multiple indexes and tables of contents?

    I have InDesign CS2.  I was wondering, is it possible to make several index? For example, an index of names, a separate index for places. Similarly, is it possible to make several Tables of contents? What I really want, it's a Table of contents, list of illustrations, a list of maps and a list of the cards.  What is the best way to go about this?  I know I can make a table of contents, copy the text and use it, then modify the toc settings to make a new. So my main concern is the index, but I'm curious to know if there is a better way for tables of contents.

    Thank you

    An InDesign document can have as many tables of contents you want, but you get only to create an index. One solution is to combine everything in a single index, and then copy and paste it into separate stories at the end. I'm a little fuzzy on the details of how get you this to sort (I never had the need, so far, to do), but it has been described here more than once. I think that a forum for several index search you would probably get the answer.

  • Using the analytic function

    Oracle 11g Release 2

    I'm assuming that the best solution is the use of analytical functions.

    create table test3
    ( part_type_id  varchar2(50)
    ,group_id      number
    ,part_desc_id  number
    ,part_cmt      varchar2(50)
    )
    /
    
    insert into test3 values( 'ABC123',1,10,'comment1');
    insert into test3 values( 'ABC123',1,10,'comment2');
    insert into test3 values( 'ABC123',2,15,'comment1');
    insert into test3 values( 'ABC123',2,15,'comment2');
    insert into test3 values( 'EFG123',25,75,'comment3');
    insert into test3 values( 'EFG123',25,75,'comment4');
    insert into test3 values( 'EFG123',25,75,'comment5');
    insert into test3 values( 'XYZ123',1,10,'comment6');
    insert into test3 values( 'XYZ123',2,15,'comment7');
    commit;
    
    select * from test3;
    
    PART_TYPE_ID           GROUP_ID PART_DESC_ID PART_CMT
    -------------------- ---------- ------------ --------------------
    ABC123                        1           10 comment1
    ABC123                        1           10 comment2
    ABC123                        2           15 comment1
    ABC123                        2           15 comment2
    EDG123                        25          75 comment3
    EDG123                        25          75 comment4
    EDG123                        25          75 comment5
    XYZ123                        1           10 comment6
    XYZ123                        2           15 comment7
    
    9 rows selected.
    
    Desired output:
    
    PART_TYPE_ID           GROUP_ID PART_DESC_ID PART_CMT
    -------------------- ---------- ------------ --------------------
    ABC123                        1           10 comment1 
    ABC123                        2           15 comment1
    XYZ123                        1           10 comment1
    XYZ123                        2           15 comment2
    
    RULE: where one part_type_id has multiple (2 or more distinct combinations) of group_id/part_desc_id
    
    NOTE: There are about 12 columns in the table, for brevity I only included 4.
    
    
    
    

    Post edited by: orclrunner was updated desired output and rule

    Hello

    Here's one way:

    WITH got_d_count AS

    (

    SELECT part_type_id, group_id, part_desc_id

    MIN (part_cmt) AS min_part_cmt

    COUNT AS d_count (*) OVER (PARTITION BY part_type_id)

    OF test3

    GROUP BY part_type_id, group_id, part_desc_id

    )

    SELECT DISTINCT

    group_id, part_desc_id, part_type_id, min_part_cmt

    OF got_d_count

    WHERE d_count > 1

    ;

    Output:

    GROUP_ID PART_DESC_ID MIN_PART_CMT PART_TYPE_ID

    ------------ ---------- ------------ ------------

    ABC123 1 10 comment1

    ABC123 2 15 comment1

    XYZ123 1 10 comment6

    XYZ123 2 15 comment7

    Analytical functions, such as the COUNTY and MIN, many global versions, in addition, it can give the same results.  Use the analytical versions when each row of output corresponds to exactly 1 row of input and the aggregate and GROUP BY version when each line of output corresponds to a group of lines 1 or more input.  In this issue, each line of output appears to be a group of input lines having the same group_id, part_type_id, and part_desc_id (I'm guessing just, this only has never stated), so I used GROUP BY to get 1 row of output for every input lines.

  • Merge no SQL using analytical functions

    Hi, the Sql tuning specialists:
    I have a question about the merger of view inline.

    I have a simple vision with the analytical functions inside. When questioning him, he does not index.


    VIEW to CREATE or REPLACE ttt
    AS
    SELECT EmpNo, deptno,
    ROW_NUMBER() over (PARTITION BY deptno ORDER BY deptno desc NULLS last) part_seq
    EMP AAA

    -That will do full table for emp scan
    Select * from TT
    WHERE empno = 7369


    -If I do not view use, I use the query directly, the index is used
    SELECT EmpNo, deptno,
    ROW_NUMBER() over (PARTITION BY deptno ORDER BY deptno desc NULLS last) part_seq
    EMP aaa
    WHERE empno = 7369


    question is: How can I force the first query to use indexes?

    Thank you

    MScallion wrote:
    What happens if you use the push_pred flag:

    Nothing will happen. And it would be a bug if he would.

    select * from ttt
    WHERE empno=7369
    

    and

    SELECT empno,deptno,
    row_number() OVER (PARTITION BY deptno ORDER BY deptno desc NULLS last) part_seq
    FROM emp aaa
    WHERE empno=7369
    

    are two logically different queries. Analytical functions are applied after + * resultset is common. So first select query all rows in the emp table then assign ROW_NUMBER() to recovered lines and only then select a line with empno = 7369 her. Second query will select the table emp with empno = 7369 line and only then apply ROW_NUMBER() - so since emp.empno is unique ROW_NUMBER returned by second query will always be equal to 1:

    SQL> select * from ttt
      2  WHERE empno=7369
      3  /
    
         EMPNO     DEPTNO   PART_SEQ
    ---------- ---------- ----------
          7369         20          4
    
    SQL> SELECT empno,deptno,
      2  row_number() OVER (PARTITION BY deptno ORDER BY deptno desc NULLS last) part_seq
      3  FROM emp aaa
      4  WHERE empno=7369
      5  /
    
         EMPNO     DEPTNO   PART_SEQ
    ---------- ---------- ----------
          7369         20          1
    
    SQL> 
    

    SY.

  • Analytical function - max_distinct

    Hello world

    (a) I have a request tht returns multiple rows for a student

    (b) to simplify my query, is columns

    Student ID, Academic_Period, student, Expected_Graduation_Date status

    (c) If a student has several status codes
    AS - active
    THE - leave

    He gets 2 rows to display.

    (d) I want to show only the rows

    Maximum preference on the Date of graduation

    (e) so I made this calc:

    MAX_DISTINCT (Expected_Graduation_Date) OVER (PARTITION BY ID.)

    and received the error:
    data types incompatible number got date scheduled

    (f) so I did:

    MAX_DISTINCT (TO_NUMBER (Expected_Graduation_Date)) OVER (PARTITION BY ID.)

    and received the error:
    invalid number

    (g) so I changed to max on alpha field of: student status
    MAX_DISTINCT (student status) OVER (PARTITION BY Id)

    and received the error:
    invalid number

    (h) is the right function to use?
    What's doing FIRST_VALUE.

    Your ideas and your advice would be appreciated, tx, Sandra

    Hello

    You need not use analytical functions. Try to create these calculations to replace the columns where there are different values:

    student_status_last = keep max (student_status) (last dense_rank order by Expected_Graduation_Date)

    Expected_Graduation_Date_last = max (Expected_Graduation_Date)

    Rod West

  • Cannot use analytical functions such as lag/lead in odi components 12 c except in the expression

    Hi I am a beginner of ODI 12 c

    I'm trying to get the last two comments made on the product for a given product id. and load them into a target.

    I have a source table something like

    Product SR_NO comments LAST_UPDATED_TS

    1 good car 2015/05/15 08:30:25

    1 car average 2015/05/15 10:30:25

    Jeep 2 super 2015/05/15 11:30:25

    1 car bad 2015/05/15 11:30:25

    Jeep 2 horrible 2015/05/15 09:30:25

    Jeep 2 excellent 2015/05/15 12:30:25


    I want a target table based on their last timestamp updated as (last two comments)


    SR_NO Comment1 Comment2

    1                             bad                      average

    2 super excellent

    I used the logic below to get records in SQL Developer but in ODI 12 c, I'm not able to do this by mapping a source to the target table by applying analytical functions to the columns in the target table. Can someone help me solve this problem

    SELECT * FROM)

    SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),

    ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)

    FROM Source_table

    ) M

    WHERE RN = 1

    ;

    UM, I'm afraid that ODI puts the filter too early in the request, if it generates:

    SELECT * FROM)

    SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),

    ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)

    FROM Source_table

    WHERE RN = 1

    ) M

    ;

    Instead of:

    SELECT * FROM)

    SELECT SR_NO Comment1, LAG(Comment1,1,) ON Comment2 (SR_NO ORDER BY LAST_UPDATED_TS ASC PARTITION),

    ROW_NUMBER() ON RN (SCORE FROM SR_NO ORDER BY LAST_UPDATED_TS DESC)

    FROM Source_table

    ) M

    WHERE RN = 1

    ;

    Even by changing the 'run on Hint"of your component of the expression to get there on the source, the request will stay the same.

    I think the easiest solution for you is to put everything before the filter in a reusable mapping with a signature of output. Then drag this reusable in your mapping as the new source and check the box "subselect enabled."

    Your final mapping should look like this:

    It will be useful.

    Kind regards

    JeromeFr

  • Which analytical function to use?


    Hi gurus,

    DB - Oracle 11 g 2

    I followed the examples of data in the table test_a.

    col1 col2 col3

    -----            -------            --------

    x                 y                   y

    p                 q                  y

    a                b                   y

    p                q                   y

    t                 r                    y

    p                q                   y

    The col3 column is always 'y '. But here's the data p, q, there is repeated 3 times (duplicate) and if this is the case I want to update only the first recordings like "n" col3 it is to say p, q, n. rest will be as it is.

    I am able to get the row_number() for it but not able to do this.

    Select col1, clo2, clo3 row_number() over (partition by col2) arrested by col1 as test_a r_num

    Would it be possible directly by any analytic function?

    Thank you

    SID

    COL4 is logical...

    Something like that?

    with x as)

    Select col1, col2 ' x' 'y', 'y' col3 col4 1 Union double all the

    Select 'p' col1, col2 'q', 'y' col3 col4 2 Union double all the

    Select 'a' col1, col2 'b', 'y' col3 col4 3 of all the double union

    Select 'p' col1, col2 'q', 'y' col3 col4 4 Union double all the

    Select 't' col1, col2 'r', 'y' col3, col4 5 Union double all the

    Select 'p' col1, col2 'q', 'y' col3 col4 6 double

    )

    ---

    Select * from)

    Select x.*,

    ROW_NUMBER() on rn1 (score of col1, col2, col3 col4 sort),

    ROW_NUMBER() on rn2 (partition by col1, col2, col3 col4 desc sorting)

    x

    )

    where rn1 = 1 and rn2 <> 1;

    Understand the logic and simply change SELECT a query to UPDATE...

Maybe you are looking for