Function MAX in OBIEE

Hi all

My problem can be summarized as follows:

I have a human resources table that stores information from the person. I then use this table in my reports. The issue is
a person may have several registers in the table and because I need to select the disc for the person, the only record
must be selected. The thing is, by an inherent logic in which the table was developed, the only way the last drive for a person can be selected
by taking the MAX (SURRO_PERSON_ID) for this person (surrogate key is the primary key for the table and is filled by a sequence, so the max will give the last disc
for this person)

I created a complex join in the RPD and since impossible to use as MAX aggregate functions in the expression to the RPD Builder, I want to know
If there is a way by which I can achieve. It would be nice if I could do the RPD itself rather than answers, but if there is no other way
so it's good.
Please let me know if you need more info.

Thank you very much.

Hello.

As I unerstood the PERSON a PERSON_ID as primary key table. Table PERSON_INFORMATION
a number of records for a single person or by a PERSON_ID so the PERSON_ID is foreign key to the PERSON table
and SURRO_PERSON_ID is the sequence (PK).

Follow these steps:

Point of view is simply select analyzed a database (it is not really an extended view in the database).

Your point of view PERSON_INFORMATION_V will be something like:

Select pi.surro_person_id,
PI.person_id,
PI.*
person_information pi
where pi.surro_person_id in
(select max (pi.surro_person_id)
of person_information where person_id = pi.person_id)

Of course, you must put all the columns you need in the select part.

Now you create a join view in a PERSON table FK physical layer:
PERSON_INFORMATION_V.PERSON_ID = PERSON. PERSON_ID

A person may have only one line in PERSON_INFORMATION_V.

MDB, you need to create 2 logical tables.

One is for the fact table and secondly for the PERSON table.

MDB to a complex join between NO logical tables and logical (before making FK join between these)
two tables in the physical layer PERSON. PERSON_ID = DONE. PERSON_ID).

In the logical table PERSON you only have a single table logic source (PERSON table) and inside in general tab, you
It should be added the physical table PERSON_INFORMATION_V and join physical it, you can do that because a person has information that one person.

So in MDB, you have a FACT and one dimension (PERSON with PERSON_INFORMATION_V flakes in there.

I hope this helps.

Concerning
Goran
http://108obiee.blogspot.com

Tags: Business Intelligence

Similar Questions

  • Calculation that uses the function Max Analytics

    Hello world

    Hope all is welll...
    I have 2 Calc:

    1) Calc_HippaToSortNumber who does:
    DECODE (hold desc, 'HIPAA', 999, NULL, 0, 500)

    2) Calc_MaxHoldDesc that uses the above calc in analytic function:
    Max (Calc_HippaToSortNumber) MORE (Student.Id PARTITION)

    I have a condition that uses the two Calc for:
    Select the line that corresponds to the max value of Calc by partition

    Calc_HippaToSortNumber = Calc_MaxHoldDesc

    I get the results I want, but I do not understand how works Discoverer:
    Calc 1 - should be the level of the detail line to assign a number based on a field to hold alpha Desc
    If keep Desc = Hippa, 999
    = Null, 0
    other values, 500

    Calc 2 - is an analytic function, so it happens after query calculates its results in detail

    BUT THE condition is testing the analytical function: this condition runs after the execution of the analytical function
    against all preliminary results?
    How does he know Scout to perform the function after execution of the analytical function
    instead of on the level of detail / row?

    The following test data:
    pls advise, tx, sandra

    ID take Fname Lname desc calc_HippatoSortNumber
    ==============================================================
    1 adams alice Certification BLS 500 max (500)
    2 Brown brett HIPAA 999 max (999)
    4 BLS Certification 500 Caroline Chin
    4 Caroline HIPAA 999 (999) max Chin

    I want to show only 3 lines using the analytical function max for the id field studying and comparing each
    the partition to the max value line and by selecting the line with the max value.
    1 adams alice BLS Certification 500
    2 Brown brett HIPAA 999
    4 Caroline HIPAA 999 Chin

    Hello

    How does he know Scout to perform the function after execution of the analytical function

    instead of on the level of detail / row?
    Discoverer always runs the latest analytical functions and therefore conditions by using analytical functions are also processed last. Discoverer for this by using a query online and therefore the structure of the SQLused

    Select Lname, Id, Calc_MaxHoldDesc, Calc_HippaToSortNumber)
    SELECT Id, Lname, DECODE (hold desc, 'HIPAA', 999, NULL, 0, 500)
    Calc_HippaToSortNumber, MAX (DECODE (hold desc, 'HIPAA', 999, NULL, 0, 500))
    ) Calc_MaxHoldDesc OVER (PARTITION BY Student.Id)
    Of...
    )
    WHERE Calc_HippaToSortNumber = Calc_MaxHoldDesc

    Rod West

  • How can I make a column of varchar (max) in OBIEE 11 g SQL?

    We use OBIEE 11 g to access a SQL 2012 database.

    The database has a column of type varchar (max).

    I tried everything that I can think to shoot in the column, including making them longvarchar, using 'Left', etc.

    But whenever I try to display the field in the answers, it will fail with a message of truncation.

    Anyone know how I can do this?

    Thanks in advance for any help you can give.

    UPDATE:

    I was able to get this to work by creating a new logical field in this way:

    Step 1. Creates a new column of logic in the business model

    Step 2. Mapped to the field as: Cast (physical column as a varchar (5000))

    I think you can go up to varchar (8000).

    I wanted to just pass this along to anyone who may be able to use it.

  • Function MAX to get the recent date does not work as expected

    Hello
    I recently started working on Oracle and came across this problem. I've coded below, given the query to obtain the most recent date in the table and compare with Sysdate + 1 timestamp. I am not able to understand what I coded wrong but the query gives me bad such results as explained below:

    Select NVL (MAX (to_char (max (last_update),' dd/mm/yyyy hh12:mi: ss AM')), to_char (sysdate + 1, ' dd/mm/yyyy') |') 12: 00')
    of Audit_Table_Name
    where col1 = 'AA '.
    and location_type = 'STATE '.
    and original_flag = 'Y '.
    Group of col1, location_type, original_flag;


    Here Max (last_update) of value Audit table contains--> 25/08/2009 12:00:00 AM
    Note: The last_update data type is Date
    If ideally, it should give 26/08/2009 12:00:00 AM, but surprisingly it gives 25/08/2009 12:00:00 AM as output. Can someone explain why this is happening and what to do to get the correct results?

    Kind regards
    Amol

    user11826653 wrote:
    Hello
    I recently started working on Oracle and came across this problem. I've coded below, given the query to obtain the most recent date in the table and compare with Sysdate + 1 timestamp. I am not able to understand what I coded wrong but the query gives me bad such results as explained below:

    Select NVL (MAX (to_char (max (last_update),' dd/mm/yyyy hh12:mi: ss AM')), to_char (sysdate + 1, ' dd/mm/yyyy') |') 12: 00')
    of Audit_Table_Name
    where col1 = 'AA '.
    and location_type = 'STATE '.
    and original_flag = 'Y '.
    Group of col1, location_type, original_flag;

    Here Max (last_update) of value Audit table contains--> 25/08/2009 12:00:00 AM
    Note: The last_update data type is Date
    If ideally, it should give 26/08/2009 12:00:00 AM, but surprisingly it gives 25/08/2009 12:00:00 AM as output. Can someone explain why this is happening and what to do to get the correct results?

    Kind regards
    Amol

    Your sysdate + 1 is the second half of your NVL function it will return only sysdate + 1 when max) last_update) is set to null. I think what you need is

    select to_char(greatest(max(last_update),trunc(sysdate)+1),'mm/dd/yyyy hh:mi:ss AM') 
    
  • Need help with the function MAX Returns the values

    I am creating a report to return slow movement inventory data. One of the requests is that it return only the last date that an item is traded on. A map shows the last date of receipt for a part, the other will show the last time, a part has been issued or shipped on a sales order.

    The hiccup is that it returns every single of the last time that an item has been received, so every last show of the material (on the second sheet) of items on-site.

    Could someone help me set the max value? As shown below, and many variations, the sheet comes up with no corrupt data or dates.

    MAX (Date of the MAX operation) (PARTITION OF matter Transactions.Item matter Transactions.Item ORDER)

    Always returns the next two when in reality, I want just the one with the date the most recent (April 2010).

    100034 BNDSCE-105 - QUALITY BEARINGS OR EQUIVALENT A400M AB01D...     Problem of component WIP $0.00 11-Sep-2009-3
    100034 BNDSCE-105 - QUALITY BEARINGS OR EQUIVALENT A400M AD01D...     Problem of component WIP $0.00 April 13, 2010-16

    Thank you for your help.

    Becka

    Hi Becka
    If you have a new calculated column showng, as in your example, 13 April 10, and you have another column that contains also this date, you should be able to create a new condition. Condition that must be the date calculated max is equal to the actual date, thus returning only the line that includes 13 April 10.

    I hope I'm makng sense

    Best wishes
    Michael

  • Error function max

    Hi all!

    I am stuck on this problem. Probably missing me something obvious, but I'd like to help. I have a query that returns rows of three:
    SELECT 1 + 1 FROM DUAL value1
    UNION ALL
    SELECT FROM DUAL 3 value1
    UNION ALL
    SELECT (3 + 5) / 2 value1 FROM DUAL;

    The result is:
    2
    3
    4

    Now, I want to find the max value of output, so I'm doing this:
    SELECT MAX)
    SELECT 1 + 1 FROM DUAL value1
    UNION ALL
    SELECT FROM DUAL 3 value1
    UNION ALL
    SELECT (3 + 5) / 2 FROM DUAL value1)
    FROM DUAL;

    ERROR on line 2:
    ORA-00936: lack of expression

    Any ideas?

    Thank you
    Abdellah
    SELECT MAX(VALUE1) FROM
    (
    SELECT 1 + 1 value1 FROM DUAL
    UNION ALL
    SELECT 3 value1 FROM DUAL
    UNION ALL
    SELECT (3 + 5) / 2 value1 FROM DUAL)
    FROM DUAL
    );
    

    Cheers, APC

    blog: http://radiofreetooting.blogspot.com

    Published by: APC on August 26, 2009 16:31

    tag broken fixed

  • Function max coupled with string concat... Please help...

    Dear all,

    I don't have to solve a query which requirements is below:

    Master data in the table looks like this:

    SEQ. NO Last_updated_date PCode

    1 AA February 1, 2008

    1 Ab January 2, 2009

    1 Ac January 3, 2009


    2 AA January 5, 2009

    2 AD December 31, 2008

    2 AF October 31, 2008


    3 AK January 1, 2009

    3 GH January 2, 2009

    3 AA January 3, 2009

    Now I need the output as:

    I need timestamp on each seqence max not (I mean groupby) (I'm really easy to find it), but it should show all pcode concated while displaying the result...

    Okay... the underside is light out put.. :

    for example in for seq 1 number one... Max timestamp is 1 February 2008 with pcode AA... so it should display as

    Seqno Pcode max (timestamp)
    ------- -------------- ----------------------

    1 AAABAC February 1, 2008

    (logical, it's she should select recording max (timestamp) and concat all the all the other pcode (only) to existing pcode eventough their timestamp is not max)

    like this for other groups of the sequence...

    Help, please... is it possible in a sqlquery to include this logic...

    Thanks for help
    ASP.

    Published by: Onenessboy on February 24, 2009 03:00

    Hello

    There is no need to hard code, replace the t table in the sub query with your table.

    Select seq_no,replace(max(pcode),'/','') pcode,min(last_updated_date) timestamp
    
    from 
    
    (Select seq_no,sys_connect_by_path(pcode,'/') pcode ,last_updated_date
    
    from t
    
    connect by prior seq_no = seq_no 
    
     and 
    
    prior last_updated_date > last_updated_date)
    
    group by seq_no
    
    /
    

    Kind regards
    Vinod

  • Syntax of the function Evaluate in OBIEE

    Hello
    I have traveled the docs but could not find the syntax for the function Evaluate. Could someone pass me the full syntax and if possible a useful example against essbase.
    Thank you

    Hello
    without a doubt

    syntax:- REVIEW ('your db function (%1, %2)', list of parameters)
    %1 and %2 here no.of (columns or constant values of May) parameters to pass to the function db
    If you have 3 parameters, you must also use %3... We hear the columns to move.

    following exapmples are for ORACLE db,
    EX1: EVALUATE ('upper (%1)', "kishore kumar") gives the result-> KISHORE KUMAR
    Ex2: EVALUATE ('upper (%1)', 'Markets.Region') Markets.Region this is column.

    Alternatively, you can call the functions defined by the user through to reassess
    Evaluate ('functioname (%1, %2), column1, column2)
    the function above has 2 parameters input

    Thank you & best regards
    Kishore Guggilla

    Published by: Kishore Guggilla, January 16, 2009 23:00

  • Field of amount but the MAX primary key

    Hello

    Is it possible to summarize a table and display the maximum value of the primary key?  The works of sum(), but I still would like to show one of the primary keys.  The maximum primary key would be great show records that were actually summed.

    CREATE TABLE TBL_EMP

    (

    NUMBER OF PK_EMP

    SITE_ID NUMBER,

    NUMBER OF FUNDS

    )

    -5 RECORDS

    INSERT INTO TBL_EMP VALUES (1, 500,10);

    INSERT INTO TBL_EMP VALUES (2, 550,20);

    INSERT INTO TBL_EMP VALUES (3, 600,30);

    INSERT INTO TBL_EMP VALUES (4, 650,40);

    INSERT INTO TBL_EMP VALUES (5, 650,50);

    SELECT PK_EMP,
    SITE_ID,
    FUND
    OF TBL_EMP

    ORDER BY SITE_ID

    -Results

    PK_EMPSITE_IDFUND
    150010
    255020
    360030
    465040
    5650

    50

    SELECT - PK_EMP,.
    SITE_ID,
    SUM (FUND) AS FUND
    OF TBL_EMP
    SITE_ID GROUP

    ORDER BY SITE_ID

    -Results

    SITE_IDFUND
    50010
    55020
    60030
    650

    90

    -If possible show the Max primary key

    PK_EMPSITE_IDFUND
    150010
    255020
    360030
    565090

    Hello

    Nikki wrote:

    Hello

    Is it possible to summarize a table and display the maximum value of the primary key?  The works of sum(), but I still would like to show one of the primary keys.  The maximum primary key would be great show records that were actually summed.

    CREATE TABLE TBL_EMP

    (

    NUMBER OF PK_EMP

    SITE_ID NUMBER,

    NUMBER OF FUNDS

    )

    -5 RECORDS

    INSERT INTO TBL_EMP VALUES (1, 500,10);

    INSERT INTO TBL_EMP VALUES (2, 550,20);

    INSERT INTO TBL_EMP VALUES (3, 600,30);

    INSERT INTO TBL_EMP VALUES (4, 650,40);

    INSERT INTO TBL_EMP VALUES (5, 650,50);

    SELECT PK_EMP,
          SITE_ID,
          FUND
    OF TBL_EMP

    ORDER BY SITE_ID

    -Results

    PK_EMP SITE_ID FUND
    1 500 10
    2 550 20
    3 600 30
    4 650 40
    5 650

    50

    SELECT - PK_EMP,.
          SITE_ID,
          SUM (FUND) AS FUND
    OF TBL_EMP
    SITE_ID GROUP

    ORDER BY SITE_ID

    -Results

    SITE_ID FUND
    500 10
    550 20
    600 30
    650

    90

    -If possible show the Max primary key

    PK_EMP SITE_ID FUND
    1 500 10
    2 550 20
    3 600 30
    5 650 90

    Use the aggregate function MAX, in the same way that you already use the SUM aggregate function:

    SELECT MAX (PK_EMP) AS max_pk_emp,

    SITE_ID,

    SUM (FUND) AS total_fund

    OF TBL_EMP

    SITE_ID GROUP

    ORDER BY SITE_ID

    ;

  • Alias MAX

    Just a small request.

    Why do we need an alias for a function MAX recover the data
    query = "SELECT MAX(changeLogID) AS CID " +
                "FROM ChangeLog " +
                "WHERE beforeUpdate like '%Status:Active%' " +
                "AND beforeUpdate like '%labID:" + labID + "%'";
    
    stmt = conn.createStatement();
    rs = stmt.executeQuery(query);
    
    while(rs.next())
    {
           System.out.println(rs.getInt("CID"));
    }
    The above code works fine as I have an alias for MAX. However, the following code generates an error
    query = "SELECT MAX(changeLogID) " +
                "FROM ChangeLog " +
                "WHERE beforeUpdate like '%Status:Active%' " +
                "AND beforeUpdate like '%labID:" + labID + "%'";
    
    stmt = conn.createStatement();
    rs = stmt.executeQuery(query);
    
    while(rs.next())
    {
           System.out.println(rs.getInt("changeLogID"));
    }
    
    java.sql.SQLException: Invalid column name
    Oracle: 91

    MAG says:
    Just a small request.

    Why do we need an alias for a function MAX recover the data

    query = "SELECT MAX(changeLogID) AS CID " +
    "FROM ChangeLog " +
    "WHERE beforeUpdate like '%Status:Active%' " +
    "AND beforeUpdate like '%labID:" + labID + "%'";
    
    stmt = conn.createStatement();
    rs = stmt.executeQuery(query);
    
    while(rs.next())
    {
    System.out.println(rs.getInt("CID"));
    }
    

    The above code works fine as I have an alias for MAX. However, the following code generates an error

    query = "SELECT MAX(changeLogID) " +
    "FROM ChangeLog " +
    "WHERE beforeUpdate like '%Status:Active%' " +
    "AND beforeUpdate like '%labID:" + labID + "%'";
    
    stmt = conn.createStatement();
    rs = stmt.executeQuery(query);
    
    while(rs.next())
    {
    System.out.println(rs.getInt("changeLogID"));
    }
    
    java.sql.SQLException: Invalid column name
    

    Oracle: 91

    changeLogID can be multiple where as Max (changeLogID), which is CID is one. That's why you get en error.

  • Grouping data with dates of Max and Min problem

    Ladies and gentlemen,

    I have a problem that I have tried from different angles. It's probably very easy for some of you, or some of you may have met before, so any help on this is greatly appreciated. I will describe below.

    I have the following data:

    User station site code dstamp ref Qty
    -------- --------- ---------- ------------- --------------------------------------------- ------- -------
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.43.06.566193000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.49.31.364224000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.49.47.413252000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.51.48.906793000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.51.56.947312000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.54.29.396052000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.54.37.444307000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.57.00.237546000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.57.04.285148000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.59.24.745162000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.59.44.774318000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 14.01.22.434940000 ref_1 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 14.01.51.291059000 ref_1 1125
    Site_1 user_1 RPT104 Activity_2 16 May 11 14.05.23.572211000 ref_2 1125
    Site_1 user_1 RPT104 Activity_1 16 May 11 14.06.01.058978000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.41.341612000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.375972000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.388699000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.401287000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.413361000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.425675000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.437360000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.449079000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.460697000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.472606000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.484031000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.495551000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.513645000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 16 May 11 14.06.49.530405000 ref_1 1125


    and I'm looking for it in this format:


    Site user station code start end ref Qty
    --------     ---------     ----------     -------------     ---------------------------------------------     ---------------------------------------------          ----------     -------
    Site_1 user_1 RPT104 Activity_1 13.43.06.566193000 16 May 11 May 16, 11 14.05.23.572211000 ref_1 1125
    Site_1 user_1 RPT104 Activity_2 14.05.23.572211000 16 May 11 May 16, 11 14.06.01.058978000 ref_2 1125
    Site_1 user_1 RPT104 Activity_1 14.06.01.058978000 16 May 11 May 16, 11 14.06.41.341612000 ref_1 1125
    Site_1 user_1 RPT104 Activity_3 14.06.41.341612000 16 May 11 (May 16, 11 14.06.49.530405000 + 4secs ref_1 1125)
    either may 16, 11 14.06.53.530405000)


    I can get the hours start and end without problem using data intial twice and it compensation by a rownum is but using the functions max and min based on the data that I get:

    Site user station code start end ref Qty
    --------     ---------     ----------     -------------     ---------------------------------------------     ---------------------------------------------          ----------     -------
    Site_1 user_1 RPT104 Activity_1 16 May 11 13.43.06.566193000 * May 16, 11 14.06.41.341612000 * ref_1 1125
    Site_1 user_1 RPT104 Activity_2 14.05.23.572211000 16 May 11 May 16, 11 14.06.01.058978000 ref_2 1125
    Site_1 user_1 RPT104 Activity_3 * 14.06.41.341612000 * 16 May 11 (May 16, 11 14.06.49.530405000 + 4secs ref_1 1125)
    either may 16, 11 14.06.53.530405000)

    who is missing on the 3rd line of the previous dataset (if everything goes well in fat after validation) and assigns the wrong time end.

    I think the solution may have soemthing to do using the function dense_rank() (any ORDER by code, start) but I'm not too familiar with it and I think that the facts in the Start column data is unique it affects its functioning.

    If anyone can offer any help or point me in the right direction I'll offer eternal grace and rest a drink we should never meet!

    see you soon

    Published by: MickyMick on June 7, 2011 03:21

    BobLilly wrote:
    Tabibitosan of Aketi method can be applied here (see {: identifier of the thread = 1005478})

    Site_1 user_1 RPT104 Activity_1 2011-05-16 13.43.06.566193000 2011-05-16 14.05.23.572211000 ref_1 1125
    Site_1 user_1 RPT104 Activity_2 2011-05-16 14.05.23.572211000 2011-05-16 14.06.01.058978000 ref_2 1125
    Site_1 user_1 RPT104 Activity_1 2011-05-16 14.06.01.058978000 2011-05-16 14.06.41.341612000 ref_1 1125
    Site_1 RPT104 Activity_3 2011-05-16 14.06.41.341612000 user_1 ref_1 14.06.45.341612000 2011-05-16 1125

    According to OP we may 16, 11 14.06.49.530405000 + 4secs. In any case, use method start_of_group:

    With t as (
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.43.06.566193000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.49.31.364224000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.49.47.413252000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.51.48.906793000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.51.56.947312000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.54.29.396052000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.54.37.444307000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.57.00.237546000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.57.04.285148000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.59.24.745162000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 13.59.44.774318000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 14.01.22.434940000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 14.01.51.291059000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_2' as Code
    , to_timestamp('16-MAY-11 14.05.23.572211000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_2' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_1' as Code
    , to_timestamp('16-MAY-11 14.06.01.058978000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.41.341612000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.375972000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.388699000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.401287000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.413361000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.425675000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.437360000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.449079000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.460697000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.472606000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.484031000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.495551000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.513645000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual union all
    Select 'Site_1' as Site, 'user_1' as Usr, 'RPT104' as Station, 'Activity_3' as Code
    , to_timestamp('16-MAY-11 14.06.49.530405000', 'DD-MON-RR HH24:MI:SS.FF') as DTStamp, 'ref_1' as Ref, 1125 as Qty from dual
    ),
    t1 as (
           select  t.*,
                   lead(DTStamp,1,DTStamp + interval '4' second) over(order by DTStamp) ENDTS,
                   case
                     when     lag(Site) over(order by DTStamp)  = Site
                          and
                              lag(Usr) over(order by DTStamp)  = Usr
                          and
                              lag(Station) over(order by DTStamp)  = Station
                          and
                              lag(Code) over(order by DTStamp)  = Code
                          and
                              lag(Ref) over(order by DTStamp)  = Ref
                          and
                              lag(Qty) over(order by DTStamp)  = Qty
                       then 0
                     else 1
                   end start_of_group
             from  t
          ),
    t2 as (
           select  t1.*,
                   sum(start_of_group) over(order by DTStamp) grp
             from  t1
          )
    select  Site,
            Usr,
            Station,
            Code,
            min(DTStamp) STARTTS,
            max(ENDTS) ENDTS,
            Ref,
            Qty
      from  t2
      group by grp,
               Site,
               Usr,
               Station,
               Code,
               Ref,
               Qty
      order by STARTTS
    /
    
    SITE   USR    STATIO CODE       STARTTS                             ENDTS                               REF          QTY
    ------ ------ ------ ---------- ----------------------------------- ----------------------------------- ----- ----------
    Site_1 user_1 RPT104 Activity_1 16-MAY-11 01.43.06.566193000 PM     16-MAY-11 02.05.23.572211000 PM     ref_1       1125
    Site_1 user_1 RPT104 Activity_2 16-MAY-11 02.05.23.572211000 PM     16-MAY-11 02.06.01.058978000 PM     ref_2       1125
    Site_1 user_1 RPT104 Activity_1 16-MAY-11 02.06.01.058978000 PM     16-MAY-11 02.06.41.341612000 PM     ref_1       1125
    Site_1 user_1 RPT104 Activity_3 16-MAY-11 02.06.41.341612000 PM     16-MAY-11 02.06.53.530405000 PM     ref_1       1125
    
    SQL> 
    

    SY.

  • How to only the totals using the native summary column (= "SUM () function

    Hi all, this is my data model:

    < name of dataTemplate 'Employees' description = 'Simple Dept - Emp' = >
    < dataQuery >
    < SQLStatement instance name = "Q1" >
    <! [CDATA]
    Select SERVICES. DEPTNO as DEPTNO,
    DEPARTMENTS. DNAME as a DNAME
    Scott. MINISTRIES DEPT order by DEPTNO]] >
    < / sqlStatement >
    < SQLStatement instance name = "Q2" >
    <! [CDATA [Select
    EMPLOYEES. ENAME like EMP_NAME,
    EMPLOYEES. EMPNO as EMPNO,
    EMPLOYEES. Hiring as HIREDATE date,
    EMPLOYEES. SAL as WAGES,
    EMPLOYEES. DEPTNO as EMP_DEPTNO
    Scott. EMPLOYEES OF THE EMP
    where EMPLOYED. [[DEPTNO =: DEPTNO]] >
    < / sqlStatement >
    < / dataQuery >
    < dataStructure >
    < name of group = "G_DEPT" source = "Q1" >
    < element name = "DEPTNO" value = "DEPTNO" / >
    < element name = "DNAME" value = "DNAME" / >
    < element name = "TOTAL_EMPS" value = "G_EMP. EMPNO"function ="COUNT ()"/ >
    < element name = "TOTAL_SALARY" value = "G_EMP. SALARY"function ="SUM ()"/ >
    < element name = "AVG_SALARY" value = "G_EMP. SALARY"function ="AVG ()"/ >
    < element name = "MAX_SALARY' value = 'G_EMP. SALARY"function ="MAX ()"/ >
    < element name = "MIN_SALARY" value = "G_EMP. SALARY"function ="MIN ()"/ >
    < name of group = "G_EMP" source = "Q2" >
    < feature name = 'EMPNO' value = 'EMPNO' / >
    < element name = "EMP_NAME" value = "EMP_NAME" / >
    < element name = "HIREDATE" value = "HIREDATE" / >
    < element name = "SALARY" value = "SALARY" / >
    < / Group >
    < / Group >
    < / dataStructure >
    < / dataTemplate >

    This datatemplate works very well with the TOTAL_EMPS, TOTAL_SALARY, AVG_SALARY, MAX_SALARY MIN_SALARY split for all departments; So these are subtotals.

    Now, I need to have the totals at the end of my report to the following:

    TOTAL_ALL_EMPS
    TOTAL_ALL_SALARY
    TOTAL_ALL_AVG_SALARY
    TOTAL_ALL_MAX_SALARY
    TOTAL_ALL_MIN_SALARY

    Add a new query (Q1) with all the totals, now the data model is the following:

    < name of dataTemplate 'Employees' description = 'Simple Dept - Emp' = >
    < dataQuery >
    < SQLStatement instance name = "Q1" >
    <! [CDATA]
    Select COUNT (empno) TOTAL_ALL_EMPS, SUM (sal) TOTAL_ALL_SALARY, AVG (sal) TOTAL_ALL_AVG_SALARY, MAX (sal) TOTAL_ALL_MAX_SALARY MIN (sal) scott TOTAL_ALL_MIN_SALARY. EMPLOYEES EMP]] >
    < / sqlStatement >
    < SQLStatement instance name = "Q2" >
    <! [CDATA]
    Select SERVICES. DEPTNO as DEPTNO,
    DEPARTMENTS. DNAME as a DNAME
    Scott. MINISTRIES DEPT order by DEPTNO]] >
    < / sqlStatement >
    < SQLStatement instance name = "Q3" >
    <! [CDATA [Select
    EMPLOYEES. ENAME like EMP_NAME,
    EMPLOYEES. EMPNO as EMPNO,
    EMPLOYEES. Hiring as HIREDATE date,
    EMPLOYEES. SAL as WAGES,
    EMPLOYEES. DEPTNO as EMP_DEPTNO
    Scott. EMPLOYEES OF THE EMP
    where EMPLOYED. [[DEPTNO =: DEPTNO]] >
    < / sqlStatement >
    < / dataQuery >
    < dataStructure >
    < name of group = "G_TOT" source = "Q1" >
    < element name = "TOTAL_ALL_EMPS" value = "TOTAL_ALL_EMPS" / >
    < element name = "TOTAL_ALL_SALARY" value = "TOTAL_ALL_SALARY" / >
    < element name = "TOTAL_ALL_AVG_SALARY" value = "TOTAL_ALL_AVG_SALARY" / >
    < element name = "TOTAL_ALL_MAX_SALARY" value = "TOTAL_ALL_MAX_SALARY" / >
    < element name = "TOTAL_ALL_MIN_SALARY" value = "TOTAL_ALL_MIN_SALARY" / >
    < / Group >
    < name of group = "G_DEPT" source = "Q2" >
    < element name = "DEPTNO" value = "DEPTNO" / >
    < element name = "DNAME" value = "DNAME" / >
    < element name = "TOTAL_EMPS" value = "G_EMP. EMPNO"function ="COUNT ()"/ >
    < element name = "TOTAL_SALARY" value = "G_EMP. SALARY"function ="SUM ()"/ >
    < element name = "AVG_SALARY" value = "G_EMP. SALARY"function ="AVG ()"/ >
    < element name = "MAX_SALARY' value = 'G_EMP. SALARY"function ="MAX ()"/ >
    < element name = "MIN_SALARY" value = "G_EMP. SALARY"function ="MIN ()"/ >
    < name of group = "G_EMP" source = "Q3" >
    < feature name = 'EMPNO' value = 'EMPNO' / >
    < element name = "EMP_NAME" value = "EMP_NAME" / >
    < element name = "HIREDATE" value = "HIREDATE" / >
    < element name = "SALARY" value = "SALARY" / >
    < / Group >
    < / Group >
    < / dataStructure >
    < / dataTemplate >

    It works fine, but my question is this:

    How can I change the data model and use the native summary column (function = "SUM (), for example) to collect data that I mentioned above (TOTAL_ALL_EMPS, TOTAL_ALL_SALARY, etc.), in order to avoid a third query SQL (Q1)?
    In a few words, I would only use the query Q2 and Q3 and have overall totals and subtotals.

    Thanks in advance for any help

    Alex




    Select 1 double DUMMY_FIELD]] >


    Select SERVICES. DEPTNO as DEPTNO,
    DEPARTMENTS. DNAME as a DNAME
    Scott. MINISTRIES DEPT order by DEPTNO]] >


    EMPLOYEES. ENAME like EMP_NAME,
    EMPLOYEES. EMPNO as EMPNO,
    EMPLOYEES. Hiring as HIREDATE date,
    EMPLOYEES. SAL as WAGES,
    EMPLOYEES. DEPTNO as EMP_DEPTNO
    Scott. EMPLOYEES OF THE EMP
    where EMPLOYED. [[DEPTNO =: DEPTNO]] >






















    Try this

    Concerning
    Charlotte

  • How to get the max of an element value selected iota AF Max.

    Hello community,

    Let me explain the scenario.

    We have a workbook of discoverer, who have several reports. These reports extract information from multiple views built specifically to retrieve information in several tables. So far, quite normal.

    Like any other report you can build these views, you can select the elements (columns) that you will use to create the report. Some of these elements (columns) are selected with the function MAX aggregate for this element; is that to say, instead of the profit of the item, and then click the SUM aggregation function, select the MAX aggregate function. With this option, we can get limit the number of search results.

    In our case, we have created a report that shows the items that we have in our stock, for each item, the report shows the sum of kilograms, the average price, its value (the sum of the average price x kilograms) for each element of the family, and we want the report to display for each item (remember that each element is a line in the report or folder) the largest number of transaction_id (of which there been selected using MAX aggregate function for the selected item), but a kind of transaction types.

    Let's see an example:

    Family | Product name | Sum of the kgs. | Units | Average price | Value of stock. Month | Year | Transaction ID | Type of transaction | Date of movement
    4420 | ALUMINA PS - M BB720 | 97.680,000 | KG | 44737 | 43.699,10 | 04. 10. 7740531 | Finalización Conjunto WIP | 16/12/2009
    4420 | ALUMINA PS - M BB720 | 47.760,000 | KG | 44737 | 21.366,39 | 04. 10. 8100110 | EXCESS | 31/03/2010
    4420 | ALUMINA PS - M BB720 | 97.680,000 | KG | 44737 | 43.699,10 | 04. 10. 8201603 | EXCESS | 30/04/2010

    Considerations:

    The value you see in the Transaction id is the maximum value that the field have; is that to say, each of the types of transactions, it shows the highest (last) transaction that id. looking at the example, the problem now is that we want to pocket the result a llitle little more. We want the report to show only from each product name or transaction id higher, either the date of circulation higher (as in the example above matches the transaction id 8201603 that have the highest movement 30/04/2010 - date).

    I stopped at that point because I don't see how to filter the data to get the result we want.

    Any suggestion or help would be appreciated, cause honestly, I don't see how.

    Thanks in advance.

    Luis.

    Hi Luis
    In order to get the last day of the month, given a year and month as strings, you will need to convert the strings to a date. Assuming you have a two-digit month and, presumably, a 2 digit, with the year 2000 year and more, then you need to start with a date and let's start with the first day of the month like this:

    To_date ('01' |: month: year, 'DDMMYY')

    You can use the ADD_MONTHS function to spend the month by one and then if you subtract 1 from that you will end up with the last day of the month.

    EndofMonth = ADD_MONTHS (TO_DATE ('01' |: month |: year, 'DDMMYY'), 1)-1

    You can also use the LAST_DAY function like this:

    EndofMonth = LAST_DAY (TO_DATE ('01' |: month |: year, 'DDMMYY'))

    Best wishes
    Michael

  • Conversions of time in OBIEE

    Hi all

    Face problems with conversions from hour to OBIEE. We use MySql database that stores the time in seconds.

    I used the following function to change in a meaningful format and created a new field in the database.

    Select from_unixtime (dateline) in the s swtickets;

    My question is, is there any function available in OBIEE administrator to change the format from seconds to the Date format.


    Thanks in advance,

    Imtiaz.

    Hi Imtiaz,

    Perhaps you could call the from_unixtime through EVALUATE function.

    Good luck

    Daan Bakboord

  • Select max (length) - how to display the length of a group MAX

    Hello

    I have a table with the name of DVD and names of files on the DVD.
    I would like to know how to change this query to get another column, MAX_LENGHT, the MAXIMUM length of the name of FILE to a DVD of return
    This doesn't work request
    select DVD, FILENAME, (SELECT max(length(FILENAME)) / 2 + 4 FROM TABLE) AS MAX_LENGHT from TABLE
    DESIRED RESULT
    DVD    FILENAME     MAX LENGHT
    DVD1     Alina     8
    DVD1     Aidan     8
    DVD1     Aiden     8
    DVD1     Akira     8
    DVD1     Alex     8
    DVD1     Alyssa     8
    DVD1     Arianna     8
    DVD1     Ashley     8
    DVD1     Ava     8
    DVD1     Benjamin8
    DVD1     Bianca     8
    DVD1     Blake     8
    DVD1     Brandon     8
    DVD1     Brayden     8
    DVD1     Brayden     8
    DVD1     Brianna     8
    DVD1     Brielle     8
    DVD1     Brooklyn8
    DVD2     Dakota     11
    DVD2     Dalia     11
    DVD2     Daniel     11
    DVD2     Dante     11
    DVD2     David     11
    DVD2     Diego     11
    DVD2     Dingbang11
    DVD2     Dominic     11
    DVD2     Dylan     11
    DVD2     Chase     11
    DVD2     Chloe     11
    DVD2     Christopher     11
    DVD2     Claire     11
    DVD2     Cole     11
    DVD2     Connor     11
    Thank you

    Roseline

    You can use the analytic version of the function max:

    SELECT  DVD
    ,       FILENAME
    ,       MAX(LENGTH(FILENAME)) OVER (PARTITION BY DVD) AS MAX_LENGTH
    FROM    TABLE
    

Maybe you are looking for