Latest record

Hi All
In a report i have the following set of records:
DISTRICT     SUB_DISTRICT     REC_TIMESTAMP
‚Ö WAYNE     ˜ÖLA SUB     12/29/2009 16:20
GREENFIELD     TIPTON SUB     12/30/2009 8:13
GREENFIELD     TIPTON SUB     12/30/2009 9:05
GREENFIELD     TIPTON SUB     12/30/2009 9:05
LA PORTE     RENSSELAER SUB     12/29/2009 16:36
LA PORTE     RENSSELAER SUB     12/29/2009 16:36
VINCENNES     PAOLI SUB     12/29/2009 15:06
VINCENNES     VINCENNES SUB     12/29/2009 16:23In the above set of records i want to show only the latest record based on the time stamp, so i used the following calculation:LAST_VALUE(Os Activity.Rec Timestamp) OVER(PARTITION BY Os Activity.Sub District )
But for some reason its giving me the following set:
DISTRICT     SUB_DISTRICT     CALCULATION     REC_TIMESTAMP
FORT WAYNE     ANGOLA SUB     12/29/2009 16:20     12/29/2009 16:20
GREENFIELD     TIPTON SUB     12/30/2009 9:05     12/30/2009 8:13
GREENFIELD     TIPTON SUB     12/30/2009 9:05     12/30/2009 9:05
GREENFIELD     TIPTON SUB     12/30/2009 9:05     12/30/2009 9:05
LA PORTE     RENSSELAER SUB     12/29/2009 16:36     12/29/2009 16:36
VINCENNES     PAOLI SUB     12/29/2009 15:06     12/29/2009 15:06
VINCENNES     VINCENNES SUB     12/29/2009 16:23     12/29/2009 16:23Can anyone please advice me where i'm going wrong?
Thanks

Please see the following set of records after i added the calculation:
DISTRICT     SUB     COUNT1     COUNT2     COUNT3     CALCULATION
FORT WAYNE     ANGOLA SUB     0     7     0     12/29/2009 16:20
GREENFIELD     TIPTON SUB     5     0     5     12/30/2009 9:05
GREENFIELD     TIPTON SUB     0     0     0     12/30/2009 9:05
GREENFIELD     TIPTON SUB     5     0     0     12/30/2009 9:05
LA PORTE     RENSSELAER SUB     0     0     0     12/29/2009 16:36
VINCENNES     PAOLI SUB     5     0     20     12/29/2009 15:06
VINCENNES     VINCENNES SUB     0     0     0     12/29/2009 16:23I used the MAX function.
Edited by: thinkingeye on Dec 30, 2009 10:59 AM

Similar Messages

  • How to get latest record on top of the result list

    Hi Gurus,
    How to get latest record on top of the result list when you open the record.
    saved data method in BT120H_CPL of OverView page and result list in ICCMP_INBOX.
    Regards,
    Ravi

    Hi
    Try sort descending by on fileld "changed at ".
    manipulate the sort depends on your requirement
    Regards
    Logu

  • How to find out the latest Record in per_all_people_f and per_all_assignme

    Hi ,
    How to find out the latest Record in per_all_people_f and per_all_assignments_f
    Requirement : Need to find out the latest record in per_all_people_f and per_all_assignments_f to update the attribute column with pre defined value . Its not possible to track only with person_id / assignment_id and effective end date
    SELECT pp_id
    FROM (SELECT app.person_id pp_id,
    asf.*
    FROM apps.per_all_people_f app,
    apps.per_all_assignments_f asf
    WHERE --app.person_id=123568 and
    asf.person_id = app.person_id AND
    app.effective_end_date = to_date('31-dec-4712') AND
    asf.effective_end_date = to_date('31-dec-4712')
    GROUP BY app.person_id)
    HAVING COUNT(pp_id) > 1
    GROUP BY pp_id
    This query also returns more than 1 value for person_id .
    It would be great if you put comment on this .. Thanks in advance ,
    Arya

    I am getting more records with asf.primary_flag='Y' . If you give ur mail id , i will send the sample data
    ASSIGNMENT_ID     EFFECTIVE_START_DATE     EFFECTIVE_END_DATE     BUSINESS_GROUP_ID     RECRUITER_ID     GRADE_ID     POSITION_ID     JOB_ID     ASSIGNMENT_STATUS_TYPE_ID     PAYROLL_ID     LOCATION_ID     PERSON_REFERRED_BY_ID     SUPERVISOR_ID     SPECIAL_CEILING_STEP_ID     PERSON_ID     RECRUITMENT_ACTIVITY_ID     SOURCE_ORGANIZATION_ID     ORGANIZATION_ID     PEOPLE_GROUP_ID     SOFT_CODING_KEYFLEX_ID     VACANCY_ID     PAY_BASIS_ID     ASSIGNMENT_SEQUENCE     ASSIGNMENT_TYPE     PRIMARY_FLAG     APPLICATION_ID     ASSIGNMENT_NUMBER     CHANGE_REASON     COMMENT_ID     DATE_PROBATION_END     DEFAULT_CODE_COMB_ID     EMPLOYMENT_CATEGORY     FREQUENCY     INTERNAL_ADDRESS_LINE     MANAGER_FLAG     NORMAL_HOURS     PERF_REVIEW_PERIOD     PERF_REVIEW_PERIOD_FREQUENCY     PERIOD_OF_SERVICE_ID     PROBATION_PERIOD     PROBATION_UNIT     SAL_REVIEW_PERIOD     SAL_REVIEW_PERIOD_FREQUENCY     SET_OF_BOOKS_ID     SOURCE_TYPE     TIME_NORMAL_FINISH     TIME_NORMAL_START     BARGAINING_UNIT_CODE     LABOUR_UNION_MEMBER_FLAG     HOURLY_SALARIED_CODE     REQUEST_ID     PROGRAM_APPLICATION_ID     PROGRAM_ID     PROGRAM_UPDATE_DATE     ASS_ATTRIBUTE_CATEGORY     ASS_ATTRIBUTE1     ASS_ATTRIBUTE2     ASS_ATTRIBUTE3     ASS_ATTRIBUTE4     ASS_ATTRIBUTE5     ASS_ATTRIBUTE6     ASS_ATTRIBUTE7     ASS_ATTRIBUTE8     ASS_ATTRIBUTE9     ASS_ATTRIBUTE10     ASS_ATTRIBUTE11     ASS_ATTRIBUTE12     ASS_ATTRIBUTE13     ASS_ATTRIBUTE14     ASS_ATTRIBUTE15     ASS_ATTRIBUTE16     ASS_ATTRIBUTE17     ASS_ATTRIBUTE18     ASS_ATTRIBUTE19     ASS_ATTRIBUTE20     ASS_ATTRIBUTE21     ASS_ATTRIBUTE22     ASS_ATTRIBUTE23     ASS_ATTRIBUTE24     ASS_ATTRIBUTE25     ASS_ATTRIBUTE26     ASS_ATTRIBUTE27     ASS_ATTRIBUTE28     ASS_ATTRIBUTE29     ASS_ATTRIBUTE30     LAST_UPDATE_DATE     LAST_UPDATED_BY     LAST_UPDATE_LOGIN     CREATED_BY     CREATION_DATE     TITLE     OBJECT_VERSION_NUMBER
    931510     7-Nov-08     31-Dec-12     122     (null)     (null)     (null)     3978     1     (null)     14402     (null)     220150     (null)     734956     (null)     (null)     476     (null)     (null)     (null)     (null)     2     E     Y     (null)     100035417-2     (null)     (null)     (null)     45948739     (null)     (null)     (null)     (null)     (null)     (null)     (null)     868007     (null)     (null)     (null)     (null)     449     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)                                        
    797386     26-Aug-08     26-Aug-08     122     (null)     (null)     (null)     3980     3     (null)     14402     (null)     218925     (null)     734956     (null)     (null)     476     (null)     (null)     (null)     (null)     1     E     Y     (null)     100035417     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     740071     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)                                        
    916076     26-Aug-08     31-Dec-12     122     (null)     (null)     (null)     3980     1     4     14402     (null)     218925     (null)     734956     (null)     (null)     476     (null)     (null)     (null)     (null)     1     B     Y     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)                                        
    797386     25-Feb-08     25-Aug-08     122     (null)     (null)     (null)     3980     1     (null)     14402     (null)     218925     (null)     734956     (null)     (null)     476     (null)     (null)     (null)     (null)     1     E     Y     (null)     100035417     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     740071     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)     (null)

  • Retrieving latest record of an employee for a same scholar ID from pa9048

    Hi Experties...!
    i want to retrieve the latest record from the pa9048 table where the scholar ID (sname) is same for an employee.........can anyone tell me how i do that..........!
    latest record in means of date.......!
    Thanx in advance................!

    Hi,
    Use the RP-PROVIDE-FROM-LAST inftytab subty beg end statement to retrieve the last record.

  • Latest record to get from MSEG Table

    Hi frnds,
    I am getting multiple records against material no. i want single record and latest one.
    SELECT DISTINCT MBLNR MATNR LIFNR
            FROM MSEG
            INTO TABLE IT_MSEG
            WHERE MATNR IN S_MATNR
            ORDER BY MATNR MBLNR DESCENDING.
    S_MATNR = multiple matnr
    eg: matnr   mblnr lifnr
          test     1        abc
          test     2        abc
          test2   4        xyz
          test3   3        abc
          test3   5        vvvv
    I want in my ITAB.
    eg: matnr   mblnr lifnr
          test     1        abc
          test2   4        xyz
          test3   5        vvvv
    Here I am sorting with mblnr to pick latest record.
    How i will get.
    Regards.

    Hi,
        just do one thing if after sorting you are getting first record of latest record in each material then use
    delete adjacent duplicates from itab comparing matnr.
    Regards
    Vijay dwivedi

  • Display latest Record First

    Hi,
    Could someone tell me where in forms builder you can configure the form so the latest record is displayed first in the application.
    As an example i query someones name in the application and i'd like to view the latest record saved to that person (there is a join between people and my new table). At the moment my custom form returns the first record entered against them.
    Thanks
    Steve

    You will have to identify this record in some way, e.g. by an increasing primary key number, or a date_created column. Then you have to order by this column in descending order in your form.

  • Can any one tell me how to select latest record

    Hi,
    Can any one tell me how to select latest record. Below is the requirement
    select * from a where a_Date=v_date.
    out of thousand records with matched condition i need to select latest record
    Thanks in advance

    user12852882 wrote:
    Can any one tell me how to select latest record. Below is the requirement
    select * from a where a_Date=v_date.
    out of thousand records with matched condition i need to select latest recordHow do you determine the "latest" row? From your description it sounds like the following SQL will define the latest:
    select max(a_date) from aThis will return the last/latest date used from the table.
    Secondly, you now want to select the last row - or rows. As a_date may not be a primary key (you did not state it was and usually a date column make poor choice as unique identifier), there could be more than one row with that "+latest date+".
    So to find the latest row(s):
    select * from a where a_date = (select max(a_date) from a)Or you could do the following:
    declare
      latestDate date;
    begin
      // find the latest date and store it for use and re-use
      select max(a_date) into latestDate from a;
      // now process the last row(s) - and consider rewriting this
      // as a bulk processing loop
      for c in (select * from a where a_date = latestDate)
      loop
        .. do something with the row
      end loop;
      // now use latestDate variable for some other
      // required processing
    .. code goes here ...
    end;

  • Latest record need to show in report

    Hi all,
    I have a requirment on shippment is as below.
    I want track a perticulat shippment based on shippment number.
    I am loading the shippment details to My ODS and the key's are 'Shippment number' and 'Date' and 'time'.
    Now my user don't want to see all the records that are relevent to perticulat shippment in bex report, he wants to see only latest record based on date and time by entering the shippment number only as input in the report.
    Can any one advice me on this, Points will be assigned.
    Regards,
    Raja reddy.

    Reddy,
    Did you try using a replacement Path variable on Date?
    If your req is to show all the shipment no.s for a date which is latest, you can do this by condition as TOPN.
    (If date is in KF list)
    But if Date is a charecteristic in the Provider, Use repl path and then put TOP N condition on it.
    Try it! You must get that.
    Cheers,
    Sri

  • Formula to get the latest record

    Hi,
    I looking to have only the last record logged displayed on my report, can any one help me with the formula ?
    Sorry,
    Actually to  be more precise I'm looking to the latest record for each equipment (where there are  many records for the equipment during the day).
    Many thanks,
    Andreia
    Edited by: andreia silva on Dec 22, 2009 3:12 PM
    Edited by: andreia silva on Dec 22, 2009 3:15 PM

    Hi,
    You could use a SQL Expression field. The following example uses the Northwind database (SQL Server) as an example.
    Type the following query in the SQL Expression editor
    (SELECT MAX("Orders"."OrderDate")
    FROM Orders
    WHERE CustomerID = Customers.CustomerID)
    Then create a record selection formula:
    {Orders.OrderDate} = {%datum}
    {%datum} is the sql expression
    When you run the report, you will see only the last order for each customer

  • Select the one record with the latest record

    I have the following table called tblSales:
    SKU   TransDate   Color
    ===   ======  ====
    123   1/1/2015    Red
    123   1/2/2015    Red
    123   1/5/2015    Red
    123   1/1/2015    White
    123   1/2/2015    White
    123   1/3/2015    White
    123   1/1/2015    Blue
    123   1/2/2015    Blue
    123   1/5/2015    Blue
    I need to create a query along the lines "SELECT the latest record FROM tblSales WHERE Color = 'White''
    In this example, the record dated 1/3/2015 would be the result.  I know that MAX(TransDate) is used here, but not sure how.
    Thanks.
    Ken

    Karl,
    I had already tried that.  It returns all 3 records having SKU = 123 and Color = White.
    Worst case scenario is I can always search for White 123s using a query with TransDate DESC and then get the first record.  I was just hoping for something a bit more elegant.
    Thanks for your help though.
    Ken

  • Fetching latest records

    Hi All,
    I want to fetch some records from a database table which are the latest entries. How can I fetch these records?
    Regards,
    Jeetu

    Hi,
    Method 1:
    1) check whether you have DATE field in your database table.
    2) fetch all records into your internal table.
    3) sort internal table by date descending.
    4) you will get the latest records on top in your internal table.
    Method 2:
    If you want only latest 10 records from your internal table
    data: begin of itab occurs 10,
    Declare your fields here make sure that you have DATE field in your internal table.
            end of itab.
    Select <fields>  from <database table> into itab.
      append itab sorted by date.
    endselect.
    note: Date should be one of teh fields of itab.

  • Latest record with active flag 'Y' (if only N, select that record)

    Hi All,
    I am having some records in table emp and need to select one record per id, which meets following criteria:-
    (1) if there is only one record for given id, select them. eg- '0154', '0155'
    (2) if more than one record then
    (2a) select record with active_flag = 'Y'.
    (2b) if more than one record with flag 'Y', select latest record where flag = 'Y'. Max eff_date.
    Emp table:-
    with emp as (
    select '0066' id, 'ABC' name, 'Y' active_flag, to_date('01-01-2009', 'dd-mm-yyyy') eff_date  from dual union
    select '0066', 'PQR', 'N', to_date('01-01-2010', 'dd-mm-yyyy') from dual union
    select '0066', 'XYZ', 'N', to_date('01-03-2010', 'dd-mm-yyyy') from dual union
    select '0154', 'PQR', 'N', to_date('01-05-2010', 'dd-mm-yyyy') from dual union
    select '0155', 'DEF', 'Y', to_date('01-05-2010', 'dd-mm-yyyy') from dual union
    select '8686', 'THY', 'N', to_date('01-10-2010', 'dd-mm-yyyy') from dual union
    select '8686', 'QWE', 'N', to_date('01-01-2010', 'dd-mm-yyyy') from dual union
    select '8686', 'POI', 'Y', to_date('01-04-2010', 'dd-mm-yyyy') from dual union
    select '8686', 'MNB', 'Y', to_date('01-03-2010', 'dd-mm-yyyy') from dual
    select * from emp;
    Output records:-
    with emp_selected as (
    select '0066' id, 'ABC' name, 'Y' active_flag, to_date('01-01-2009', 'dd-mm-yyyy') eff_date  from dual union
    select '0154', 'PQR', 'N', to_date('01-05-2010', 'dd-mm-yyyy') from dual union
    select '0155', 'DEF', 'Y', to_date('01-05-2010', 'dd-mm-yyyy') from dual union
    select '8686', 'POI', 'Y', to_date('01-04-2010', 'dd-mm-yyyy') from dual
    select * from emp_selected;Request you to please look at it.
    Regards,
    Ritesh

    Thanks for posting the sample data and expected resutls in such a useful way. It makes life so much easier.
    Assuming that the only valid values in active_flag are Y and N, and that there are no nulls, then this is one way:
    SQL > with emp as (
      2   select '0066' id, 'ABC' name, 'Y' active_flag, to_date('01-01-2009', 'dd-mm-yyyy') eff_date  from dual union
      3   select '0066', 'PQR', 'N', to_date('01-01-2010', 'dd-mm-yyyy') from dual union
      4   select '0066', 'XYZ', 'N', to_date('01-03-2010', 'dd-mm-yyyy') from dual union
      5   select '0154', 'PQR', 'N', to_date('01-05-2010', 'dd-mm-yyyy') from dual union
      6   select '0155', 'DEF', 'Y', to_date('01-05-2010', 'dd-mm-yyyy') from dual union
      7   select '8686', 'THY', 'N', to_date('01-10-2010', 'dd-mm-yyyy') from dual union
      8   select '8686', 'QWE', 'N', to_date('01-01-2010', 'dd-mm-yyyy') from dual union
      9   select '8686', 'POI', 'Y', to_date('01-04-2010', 'dd-mm-yyyy') from dual union
    10   select '8686', 'MNB', 'Y', to_date('01-03-2010', 'dd-mm-yyyy') from dual)
    11   SELECT id, name, active_flag, eff_date
    12   FROM (SELECT id, name, active_flag, eff_date,
    13                ROW_NUMBER() OVER(PARTITION BY id
    14                                  ORDER BY active_flag desc, eff_date desc) rn
    15         FROM emp)
    16   WHERE rn = 1;
    ID   NAM A EFF_DATE
    0066 ABC Y 01-JAN-09
    0154 PQR N 01-MAY-10
    0155 DEF Y 01-MAY-10
    8686 POI Y 01-APR-10If there could be nulls in active_flag, then you could use NVL to set the value to Y or N in the order by to sort it "correctly" based on your requirements.
    If there could be values other than Y and N, then use a case statement in the order by to fix the order to give preference to what you want.
    For example, if valid values could be Y, N, P and you wanted them selected in that order, then neither ascending nor descending sorts would be right, so you could do something like:
    ORDER BY CASE active_flag WHEN 'Y' THEN 1
                              WHEN 'N' THEN 2
                              WHEN 'P' THEN 3
                              ELSE 4 ENDJohn

  • Returning latest records based on specific conditions

    Hi Everyone, Thanks for everyone response for my queries. All responses are highly appreciated. I need one help in developing Sql query. I am
    using Oracle 11.2.
    I have table Test as below having columns as, ID;Name;Position;Level;Date_Added;Flag_Name;
    Suppose I have below data in table:
    ID       Name      Position      Level              Date_Added                Flag_Name
    1       Jack       Manager        10         10/29/2013 11:00:00 PM          Match
    2       Tom        Supervisor     20            10/31/2013 9:00:00 AM       NoMatch
    1       Jack       Manager        15          11/1/2013  10:00:00 AM          Error
    1       Jack       Manager        20         10/1/2013  9:00:00 AM           NoMatch
    3       John       Salesman      5           10/4/2013  2:00:00 PM           Error
    1       Jack       Manager        17         9/28/2013  2:00:00 AM           NoMatch
    2       Tom        Supervisor     12         11/2/2013  10:00:00 AM          NoMatch
    4       Remy       Accountant     12        11/4/2013  1:00:00 PM           Error
    4       Remy       Accountant     19         11/3/2013  2:00:00 AM           Error
    2       Tom        Supervisor     10            10/29/2013 7:00:00 PM           Error
    I need to return latest data in query based on combination of (ID;Name;Position) and date range with below conditions:
    1) Need to return latest records for Flag_Name other than Match.
    2) If latest record for combination of (ID;Name;Position) will come with Flag_Name as Error in that specified date range, then we need to look for this combination has Flag_Name as NoMatch anywhere before in table.
    3) If Flag_Name as NoMatch is found for this, then we need to return it. In this case also, if we found multiple records with Flag_Name as NoMatch for combination of (ID;Name;Position), then we need to return latest one.
    4) Else we find no record for combination of (ID;Name;Position) with Flag_Name as NoMatch in table, then we can return the latest record with Flag_Name as Error.
    While select ID;Name;Position should be unique combination, as we always return latest data for it.
    As per above table, if I need to return data for date range between 29-Oct-2013 and 5-Nov-2013, expected result will be like below:
    ID       Name      Position      Level         Date_Added                      Flag_Name    
    1       Jack       Manager        20              10/1/2013  9:00:00 AM           NoMatch
    2       Tom        Supervisor     12             11/2/2013  10:00:00 AM          NoMatch
    3       John       Salesman        5              10/4/2013  2:00:00 PM           Error
    4       Remy       Accountant     12           11/4/2013  1:00:00 PM           Error
    Please let me know if anyone has any doubt about the logic. Is it possible if we can do it in select statement rather than pl/sql code?
    All comments/suggestions will be highly appreciated.
    Thanks in advance.
    Regards
    Dev    

    First i didn't read topic exactly )))
    here is second way. I get with stmt from Karthick (thanks)
    with t
        as
        select 1 id, 'Jack' name, 'Manager'    position, 10 lvl, to_date('10/29/2013 11:00:00 PM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Match'   flag_name
          from dual union all
        select 2 id, 'Tom'  name, 'Supervisor' position, 20 lvl, to_date('10/31/2013 09:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'NoMatch' flag_name
          from dual union all
        select 1 id, 'Jack' name, 'Manager'    position, 15 lvl, to_date('11/1/2013  10:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error'   flag_name
          from dual union all
      select 1 id, 'Jack' name, 'Manager'    position, 20 lvl, to_date('10/1/2013  09:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'NoMatch' flag_name
        from dual union all
      select 3 id, 'John' name, 'Salesman'   position,  5 lvl, to_date('10/4/2013  02:00:00 PM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error'   flag_name
        from dual union all
      select 1 id, 'Jack' name, 'Manager'    position, 17 lvl, to_date('9/28/2013  02:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'NoMatch' flag_name
        from dual union all
      select 2 id, 'Tom'  name, 'Supervisor' position, 12 lvl, to_date('11/2/2013  10:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'NoMatch' flag_name
        from dual union all
      select 4 id, 'Remy' name, 'Accountant' position, 12 lvl, to_date('11/4/2013  01:00:00 PM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error'   flag_name
        from dual union all
      select 4 id, 'Remy' name, 'Accountant' position, 19 lvl, to_date('11/3/2013  02:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error'   flag_name
        from dual union all
      select 2 id, 'Tom'  name, 'Supervisor' position, 10 lvl, to_date('10/29/2013 07:00:00 PM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error'   flag_name
        from dual
    select ID,
           Name,
           Position,
           max(lvl) keep (dense_rank first order by с desc, Date_Added desc) lvl,
           max(Date_Added) keep (dense_rank first order by с desc, Date_Added desc) Date_Added,
           min(Flag_Name) keep (dense_rank first order by с desc, Date_Added desc) Flag_Name
    from(
    select  ID,
                Name,
                Position,
                lvl,
                Date_Added,
                Flag_Name,           
                decode(flag_name, 'Error', -1, 1) с
    from T
    where flag_name != 'Match'
    group by ID,Name,Position
    ID
    NAME
    POSITION
    LVL
    DATE_ADDED
    FLAG_NAME
    1
    Jack
    Manager
    20
    01.10.2013 09:00:00
    NoMatch
    2
    Tom
    Supervisor
    12
    02.11.2013 10:00:00
    NoMatch
    3
    John
    Salesman
    5
    04.10.2013 14:00:00
    Error
    4
    Remy
    Accountant
    12
    04.11.2013 13:00:00
    Error
    Ramin Hashimzade
    Message was edited by: RaminHashimzadeh

  • How to get only the latest record in a folder

    Hi all,
    We have an OA SIT that is not a "standard" SIT in that it does not have the traditional Begin and End date. It only has an Effective date. Is there some way I can filter this table to only give me the latest record in the series? I know how to do this in SQL, but don't see how it would be possible in the EUL.
    We're trying to avoid creating database views, but at this point, I'm thinking it may be the easiest way to address this. Any other suggestions?
    Thanks in advance,
    Jewell

    Jewell.
    Of course I'm not going to mention that I have no idea what a 'standard' SIT is compared to your basic 'non-standard' SIT ... and I have to watch my spelling of such ... but however ...
    As you're most likely aware, in SQL you would get all the 'standard' SIT records first by going through the table. Then you'd go back through them all and find the most recent one.
    Because of this 2 table pass, I agree that just putting the SQL code in a custom folder (as you're not using views) would make the most sense.
    Russ

  • Query  to find 10 latest records

    hi all,
    i have 100 records with following attributes.
    username
    mobile no
    date
    i want to select 10 latest rocords for a perticular mobile no(based on date attribute).
    regards,
    uttam

    Hi Mohan,
    I would use the same analytic function to get the records. However, I will have to modify the expression to get the records starting from the latest date as posted by Uttam. I just added the option DESC to start from the latest record and run down to the earliest.
    select * from(
    select username, mobile_no, date,
    rank() over(partition by mobile_no order by date DESC) rn
    from tabl1)
    WHERE rn<=10;

Maybe you are looking for

  • Can you please help me find out...

    Hi. How can I drag and drop music into a iPod from a computer and get it to work? My computer will not work with iTunes, so I need to know this... Thanks.

  • Cant figure out whats wrong with my applet, help pls??

    this applet checks a string against one in a database then if passwords match, a new url is opened. the applet loads in webpage with no problems. it just doesnt seem to work. have granted full access to code base in policy file. heres the code: impor

  • How to hide the Parameters?

    Hi all,          I Have two parameters in a report. I need to hide one paramerter when another one is selected and vice versa. Kindly give me the solution. Thanks for your support in advance. Thanks  & Regards, Shiva

  • Dealer Portal - Vehicle Sales -  Maintain more selection Criteria

    Hi, In Dealer Portal, Vehicle Sales --> Work Overview, I am getting the below error. Error message: Maintain more selection Criteria. What configuration is missing? I am Portal consultant, Please provide step by step procedure to fix this. Kindly sup

  • Adobe Reader 11.0.07 - mouse cursor full screen mode

    Hello, After the security update to Adobe Reader 11.0.07 I noticed a bug in full screen mode - the mouse cursor is not hidden after delay even if this option is chosen in Preferences. How can be resolved this problem?