Select the most recent DATE for identification.

Hi all

I need to SELECT records with the most recent DATE for each code. A DATE range is part of the selection criteria.

My data.
MY_ID MY_DATE
1684662 26 JANUARY 09
1424097 27 JANUARY 09
1684663 27 JANUARY 09
1684664 27 JANUARY 09
1684672 28 JANUARY 09
0689073 28 JANUARY 09
1052476 21 JANUARY 09
1052476 21 JANUARY 09
1360828 23 JANUARY 09
1684661 23 JANUARY 09
1052476 30 JANUARY 09
1052476 30 JANUARY 09
1052476 30 JANUARY 09
1052476 30 JANUARY 09

The code below works fine when you select 1 ID in the subselect, but with several ID he always selects rownum = 1 (of course). As far my mind takes me.
SELECT my_id,
my_date
Of
(SELECT my_id,
my_date
FROM my_table
ORDER BY DESC my_date
)
WHERE rownum = 1
AND * {color: #ff0000} my_id = 1052476 {color} *.
AND TO_CHAR(my_date,'YYYY/MM/DD') BETWEEN ' 01 / 01/2009 ' AND '' 2009/01/31;

If I could somehow pass the ID SELECT in the subselect WHERE clause I should have done this.

Any suggestions?

Thanks in advance for your help,

Lou

One of the many soultions possible.

ME_XE?with data as
  2  (
  3     select 1684662 as id, to_date('26-JAN-09','dd-mon-yyyy') as the_date from dual union all
  4     select 1424097 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all
  5     select 1684663 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all
  6     select 1684664 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all
  7     select 1684672 as id, to_date('28-JAN-09','dd-mon-yyyy') as the_date from dual union all
  8     select 0689073 as id, to_date('28-JAN-09','dd-mon-yyyy') as the_date from dual union all
  9     select 1052476 as id, to_date('21-JAN-09','dd-mon-yyyy') as the_date from dual union all
 10     select 1052476 as id, to_date('21-JAN-09','dd-mon-yyyy') as the_date from dual union all
 11     select 1360828 as id, to_date('23-JAN-09','dd-mon-yyyy') as the_date from dual union all
 12     select 1684661 as id, to_date('23-JAN-09','dd-mon-yyyy') as the_date from dual union all
 13     select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all
 14     select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all
 15     select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all
 16     select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual
 17  )
 18  select id, the_date
 19  from
 20  (
 21     select id, the_date, max(the_date) over (partition by id) as max_the_date
 22     from data
 23  )
 24  where the_date = max_the_date;

                ID THE_DATE
------------------ --------------------------
            689073 28-JAN-0009 12 00:00
           1052476 30-JAN-0009 12 00:00
           1052476 30-JAN-0009 12 00:00
           1052476 30-JAN-0009 12 00:00
           1052476 30-JAN-0009 12 00:00
           1360828 23-JAN-0009 12 00:00
           1424097 27-JAN-0009 12 00:00
           1684661 23-JAN-0009 12 00:00
           1684662 26-JAN-0009 12 00:00
           1684663 27-JAN-0009 12 00:00
           1684664 27-JAN-0009 12 00:00

                ID THE_DATE
------------------ --------------------------
           1684672 28-JAN-0009 12 00:00

12 rows selected.

Elapsed: 00:00:00.03

Tags: Database

Similar Questions

  • by selecting the most recent decisiondate for a client, not all dates...

    Hello

    Consider the following situation:
    I have 4 tables:


    PD_CLIENT
    CLIENT_ID
    RNR
    .. more data .the customer...

    PD_LINKCLIENTCOMPOSITION
    COMPOSITION_ID
    CLIENT_ID
    LEVEL_ID

    PD_COMPOSITIONLEVEL
    LEVEL_ID
    LEVEL
    S_TYPE

    PD_LINKCLIENTDECISION
    DECISION_ID
    DATE_DECISION
    CLIENT_ID


    Some info with these tables
    There are the customers
    Customers have a composition one or several compositions have levels and these compositionlevels have different types
    For customers, the decisions are made on a certain date. Sometimes it is possible to have more than one decision of a customer.

    (the actual database is much larger than that, but I left out that we don't need to my question)

    I need is:_
    ALL customers, who have a composition with the leveltype "IGO", as well as the date of their most recent decision between 2 dates given. (if they do not have a decision yet, I do not need them in the results)

    I wrote this query:
    SELECT PD_CLIENT.CLIENT_ID, TO_CHAR(PD_LINKCLIENTDECISION.DATE_DECISION, 'DD-MM-YYYY') DATE_DECISION 
    FROM PD_CLIENT , PD_LINKCLIENTCOMPOSITION , PD_COMPOSITIONLEVEL, PD_LINKCLIENTDECISION 
    WHERE PD_CLIENT.CLIENT_ID = PD_LINKCLIENTCOMPOSITION.CLIENT_ID 
    AND PD_LINKCLIENTCOMPOSITION.COMPOSITION_ID = PD_COMPOSITIONLEVEL.NIVEAU_ID 
    AND PD_CLIENT.CLIENT_ID = PD_LINKCLIENTDECISION.CLIENT_ID
    AND PD_COMPOSITIONLEVEL.S_TYPE = 'IGO' 
    AND PD_LINKCLIENTDECISION.DATE_DECISION >= TO_DATE('01-01-2011', 'DD-MM-YYYY') 
    AND PD_LINKCLIENTDECISION.DATE_DECISION <= TO_DATE('31-12-2011', 'DD-MM-YYYY') 
    ORDER BY PD_CLIENT.RNR ASC
    This ALMOST gives me what I need. now it gives me the client_id, gives with ALL dates of decision between 2 dates. I only need the newest one. Can someone help me change that? It is probably something small. I thought I knew how to solve, but I continue to not now, I have not any more close to the result with this query :)

    Published by: 901981 on 16-dec-2011 05:46

    How about some analytics?
    Try something like:

    not tested

    select client_id
    ,      date_decision
    from (
          SELECT PD_CLIENT.CLIENT_ID,
                 TO_CHAR(PD_LINKCLIENTDECISION.DATE_DECISION, 'DD-MM-YYYY') DATE_DECISION,
                 row_number() over (partition by PD_CLIENT.CLIENT_ID order by PD_LINKCLIENTDECISION.DATE_DECISION desc ) rn
            FROM PD_CLIENT,
                 PD_LINKCLIENTCOMPOSITION,
                 PD_COMPOSITIONLEVEL,
                 PD_LINKCLIENTDECISION
           WHERE PD_CLIENT.CLIENT_ID = PD_LINKCLIENTCOMPOSITION.CLIENT_ID
             AND PD_LINKCLIENTCOMPOSITION.COMPOSITION_ID =
                 PD_COMPOSITIONLEVEL.NIVEAU_ID
             AND PD_CLIENT.CLIENT_ID = PD_LINKCLIENTDECISION.CLIENT_ID
             AND PD_COMPOSITIONLEVEL.S_TYPE = 'IGO'
             AND PD_LINKCLIENTDECISION.DATE_DECISION >= TO_DATE('01-01-2011', 'DD-MM-YYYY')
             AND PD_LINKCLIENTDECISION.DATE_DECISION <= TO_DATE('31-12-2011', 'DD-MM-YYYY')
          )
    where rn=1;  
    
  • The most recent data in a table view

    I'm adding values to a bulletin board as in the example, but I want to be the most recent data for the user to see the top line.

    He keeps adding to the bottom, and then the user will have to Diecut down see all data.      Can I select the most recent data somehow or get auto-scrolling data table are applied?     I tried registers to shift as well, but no luck.

    Here's my VI

    Thank you

    Mike

    Have you read the help of the function insert in the table? He clearly says that if you leave the unwired index entries, it will insert at the end. So, don't let the unwired index entries. Wire a '0' to the row index.

  • How to get the values based on the most recent date

    Oracle Version 8i



    How to get the new_value based on the most recent date

    SELECT max (MODIFIED_ON), the Group LOG_ITEM_CHARACTERISTICS by MODIFIED_ON new_value - does not

    Please, someone help me
    CREATE TABLE LOG_ITEM_CHARACTERISTICS
    (
      CHAR_LOG_ID          NUMBER(10)               NOT NULL,
      PIRM_ID              VARCHAR2(8)              NOT NULL,
      CONSTANT_FLAG        VARCHAR2(1),
      CHARACTERISTIC_NAME  VARCHAR2(25)             NOT NULL,
      TYPE_NAME            VARCHAR2(10)             NOT NULL,
      NEW_VALUE            VARCHAR2(3000),
      UOM                  VARCHAR2(10),
      MODIFIED_BY          VARCHAR2(30),
      MODIFIED_ON          DATE
    )
    
    SET DEFINE OFF;
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (187376, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '1', 'AMPS', 'EMPXD88', TO_DATE('10/25/1999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (187377, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMPXD88', TO_DATE('09/22/1998 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (187378, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '0', 'AMPS', 'EMDXB88', TO_DATE('09/22/1998 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (187384, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '2', 'AMPS', 'EMAXC29', TO_DATE('11/10/2000 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (187385, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55.1', 'VOLTS', 'EMAXC29', TO_DATE('10/19/2001 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_ON)
     Values
       (2400742, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '2', 'AMPS', TO_DATE('10/19/2001 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (574093, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '2', 'AMPS', 'EMCTH88', TO_DATE('12/13/2002 11:55:16', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (574094, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMCTH88', TO_DATE('12/13/2002 11:55:16', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (3131486, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (3131487, '0307490N', 'N', 'LAST MEASURED DATE', 'PS2030/WVL', '16-12-04', 'DD/MM/YY', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (3131488, '0307490N', 'Y', 'POWER SUPPLY', 'PS2030/WVL', 'ESSENTIAL', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (3131489, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (4759086, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (4759087, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (4759088, '0307490N', 'N', 'LAST MEASURED DATE', 'PS2030/WVL', '14/11/07', 'DD/MM/YY', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (6646012, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '5', 'AMPS', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6646013, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6646014, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (6646015, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6646016, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6646057, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6646058, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6646059, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (6648577, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (6648578, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6648579, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6648580, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:36:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON)
     Values
       (6648581, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:36:10', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (6648634, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '5', 'AMPS', 'EMPXD88', TO_DATE('01/07/2011 13:51:06', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into LOG_ITEM_CHARACTERISTICS
       (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON)
     Values
       (6648635, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'EMPXD88', TO_DATE('01/07/2011 13:51:06', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;

    user4587979 wrote:
    Hi Frank

    Yes, but I had more than 2 tables with item_characteristics, type_characteristics

    If there are other tables involved, then CREATE TABLE and INSERT statements for them (for the relevant columns only). You must not post a lot of examples of data; usually just a couple of lines per table is enough to show the problem.
    Also post the results desired from these data.

    What I try to do is, I'm comparing new_value in log_item_characteristics (whichever is most recent) with CHR_VALUE in the item_characteristics and the needs of different output values

    I am trying to query is not giving desired out put

    Point out some places where the output is wrong and explain how you get good results in these places, using specific examples from the data sample.

    select  lic.PIRM_ID, ic.CHR_ID, lic.CHARACTERISTIC_NAME,
    lic.TYPE_NAME, ic.CHR_VALUE, lic.NEW_VALUE,  lic.MODIFIED_BY,  lic.MODIFIED_ON,
    ic.CREATED_BY, ic.CREATED_ON,ic.MODIFIED_BY, ic.MODIFIED_ON
    from log_item_characteristics lic, item_characteristics ic,type_characteristics tc  where
    lic.TYPE_NAME=tc.TYPE_NAME
    and lic.CHARACTERISTIC_NAME=tc.CHR_NAME
    and lic.PIRM_ID=ic.PIRM_ID
    and tc.CHR_ID=ic.CHR_ID and ic.CHR_VALUE <> lic.NEW_VALUE
    and lic.pirm_id in ('0307490N','0307521C')
    order by lic.pirm_id
    

    Thank you; It is useful to see the existing query. Really, you have to format your code.

    Please can you help me

    What you've posted so far is like saying "I'm going 200 meters to the North, and then 500 meters East, but I'm not getting where I want to go." I would have a better chance to help you if you said, 'I'm out of my house, at 100, Elm Street and try to get to the supermarket at Broadway 279. I'm going 200 meters to the North... ', or, even better. "I want to buy a newspaper and some orange juice, so I thought I'd go to a convenience store. I start at my house, at 100, Elm Street... »
    Always post some examples of data (CREATE TABLE and INSERT statements, as you did in your first post) and the desired results from these data. Explain how you get these results from these data.

  • The most recent date in the report filter.

    Hello

    I have a report with a date column. I would like to run the report for the most recent date. I want to add a filter to the report that retrieves data for the latest in date. What would be the best method to use in the filter. Please notify. Thank you.

    You must first determine what the column that contains the dates on which you want to filter. Say so you have a Date of treatment column containing dates transactions are processed.

    (1) add this column in your workspace.

    2) click this column filter button, and then click Advanced Options > convert this filter in SQL.

    (3) after the name of the column, enter MAX (date_column). So you will have:

    "Table name". " "Date column ' = MAX ("Table name". ("' Date column")

    Now the chances are that you will have a lot of reports who need the "latest date" filter. Therefore, you should really do is built that filter in the repository and expose it as a filter registered for all to use.

  • Need help get data with the most recent date of entry into

    Hey guys;

    I need help with fine tuning a query to get the one with the most recent implementation.

    Here's my current query:

    /**********************************************
    Select sge.seal_group_id,
    SGE.equipment_id,
    SGE.effective_date
    of seal_group_equipment EMS.
    seal_group sg
    where equipment_id = 48801
    AND EMS. SEAL_GROUP_ID = SG. SEAL_GROUP_ID
    and sge.end_date is null
    Group of sge.equipment_id, sge.seal_group_id, sge.effective_date
    After having sge.effective_date = max (sge.effective_date)

    ******************************************************/

    Which produces the following results:
    SEAL_GROUP_ID - EQUIPMENT_ID - EFFECTIVE_DATE
    25-48801 - 01/01/1993-00: 00:00
    11730-48801 - 22/08/2003 08:42:11


    What I really need, is to show only the line with the most recent date of entry into
    I hope someone can help
    Thank you

    MAX will not work because the SEAL_GROUP_ID could depart. I would say analytical:

    select seal_group_id,
    equipment_id,
    effective_date
    from (
    select sge.seal_group_id,
    sge.equipment_id,
    sge.effective_date,
    RANK() over (partition by equipment_id order by effective_date desc) r
    from seal_group_equipment sge,
    seal_group sg
    where equipment_id = 48801
    AND SGE.SEAL_GROUP_ID = SG.SEAL_GROUP_ID
    and sge.end_date is null)
    where r = 1;
    

    Keep in mind if two records have the same effective_date, they would both appear.

    Note: query above has not been tested, since there is no script provided.

  • Backup utility Windows 7 application ' are you sure you want to remove the most recent data from the backup file "even if I'm trying to remove the backup set is not the most recent.

    I'm trying to reduce the amount of space that my Windows 7 backup uses so I've come to the place in Windows 7 backup:
    Manage space > view backups...

    I am then presented a list of three backup sets:
    01/03/2012 to 01/04/2012
    12/07/2011 to 12/21/2011
    23/11/2011 to 30/11/2011

    I would like to remove the older two, leaving the most recent. However, this doesn't seem to work as expected. If I try to delete one of the two most recent ones (the first two in the list above) I get the following warning "Are you sure you want to delete this backup file.

    However, if I try to delete the last one in the list, I get a slightly different error "Are you sure you want to remove the most recent data of the file backup?"-sounds strange because it is clearly not the most recent backup according to the dates it's show.

    Of course, I can go ahead and ignore the warnings, but I fear that maybe there are some files in the last backup the value in the list that may not be right more recent set backs.

    In 2011, I thought this might be something wrong with the date formats vs US UK (I am in England so the above dates are in dd/mm/yyyy format and not in jj/mm/aaaa) - but now it's 2012 and I backup from 2012 and 2011 games and he always seems to think that the oldest backup of 2011 is the most recent.

    Any ideas? Can I delete the oldest backup sets (that is, the two that are from 2011) safely?

    Any help much appreciated - thank you.

    Simon

    Update: I checked on other PCs in the office and the situation is the same - is not only something strange on a PC.

  • How to find the most recent date prev?

    Hello

    Here is the sample table and sample data.
    CREATE TABLE t1 (code NUMBER, dt DATE, price NUMBER)
    /
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/21/2012', 'MM/DD/YYYY'), 10);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/22/2012', 'MM/DD/YYYY'), 10);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/23/2012', 'MM/DD/YYYY'), 12);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/24/2012', 'MM/DD/YYYY'), 9);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/25/2012', 'MM/DD/YYYY'), 8);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/26/2012', 'MM/DD/YYYY'), 13);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/27/2012', 'MM/DD/YYYY'), 11);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/28/2012', 'MM/DD/YYYY'), 15);
    Insert into T1 (CODE, DT, PRICE) Values (2, TO_DATE('10/29/2012', 'MM/DD/YYYY'), 15);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/30/2012', 'MM/DD/YYYY'), 13);
    Insert into T1 (CODE, DT, PRICE) Values (1, TO_DATE('10/31/2012', 'MM/DD/YYYY'), 13);
    COMMIT;
    I have to read the table so that I got when I read a line of CODE = 1 for DT = 30 - OCT - 2012, I have to check what was the price for the CODE = 1 in the most recent previous date (which is October 28, 2013). Then I will compare the two prices (for 30 Oct 28th) and fill out another table.

    I hope I have described the situation well.

    Could someone help me with this please?

    My actual table contains a few million lines in DEV env and a lot more in PROD.

    Thanks in advance!

    If you use the analytical function LAG you can 'Watch' data of previous lines...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select code, dt, price
      2        ,lag(price) over (partition by code order by dt) as prev_price
      3* from t1
    SQL> /
    
          CODE DT                        PRICE PREV_PRICE
    ---------- -------------------- ---------- ----------
             1 21-OCT-2012 00:00:00         10
             1 22-OCT-2012 00:00:00         10         10
             1 23-OCT-2012 00:00:00         12         10
             1 24-OCT-2012 00:00:00          9         12
             1 25-OCT-2012 00:00:00          8          9
             1 26-OCT-2012 00:00:00         13          8
             1 27-OCT-2012 00:00:00         11         13
             1 28-OCT-2012 00:00:00         15         11
             1 30-OCT-2012 00:00:00         13         15
             1 31-OCT-2012 00:00:00         13         13
             2 29-OCT-2012 00:00:00         15
    
    11 rows selected.
    
  • Amount for the most recent date

    Hi all

    Pls help me to write this query, im using db oracle 11.2. I have a requirement as below

    This how my table looks like...

    CREATE_DATE LINE_ID QUANTITY
    APRIL 1, 2013 10001 1500
    APRIL 1, 2013 10001 300
    19 APRIL 2013 10001 1500
    19 APRIL 2013 10001 300

    I want that my request to return it...

    CREATE_DATE LINE_ID QUANTITY
    19 APRIL 2013 10001 1800

    What is the easiest way to write this query?

    Select

    Max (create_date) create_date

    line_id

    , Sum (Quantity) keep (first order by desc create_date dense_rank) AMOUNT

    from your_table

    Line_id group

    CREATE_DATE LINE_ID QUANTITY

    19.04.2013 "10001" "1800".

  • How to get data hardbounce retrospective of the most recent date?

    I want out of backdata Hard bounce by last date using the API.

    Can someone help me?

    Any suggestion is appreciated.

    Kind regards

    Shashi Kant

    BLOCK has an API "/ activities" endpoint, you can use to define an excerpt. You can programmatically add a filter him every time you kick off your snippet (something like ActivityDate > = and set the current date as the side right of the > = parameter). You can then use the ' /extracts/data "endpoint to extract the data returned by eloqua sync. See the documentation for the API BLOCK to get an idea of a typical eloqua extraction process.

  • MY POP3 accounts receive emails with lack and truncated attached files. This started only after the most recent update for Thunderbird Version 38.1.0

    I recently started having truncated the attachments in the emails to my POP3 accounts. The first I noticed was on 27 July 2015.
    I'm running Thunderbird Version 38.1.0 on Windows on Windows 7 Home Premium service pack 1. After the test, I found that this happens on all POP3 accounts only. IMAP accounts do not work properly.
    A single file is usually truncated, if I send several files to get a complete file one truncated and more sent are missing completely.

    I wanted to send a bug report, but your system is unusable because it asks us to load the daily accumulation and essay on a new account, but the link to the daily version is going nowhere. But it's ok

    Thank you

    Thanks Matt.
    I had no luck by disabling addons, and I found that I'm unable to start in SafeMode (another problem to solve), but in research and the elimination of other culprits (malware) this problem stopped.

  • Unable to connect after the most recent firmware for Microsoft Surface Pro 3 update

    Hi, I upgraded my Surface Pro to Windows 10 2... had no problems connecting to R7000 on band 5G. After upgrade the R7000 firmware to the latest version (V1.0.4.30_1.1.67), I now have problems connecting on the band of 5 G. Tablet must be adjacent to the router to connect on 5G band however once connected is connection is kept at distance (about 50 feet). However if I choose the 2.4GH I have no problem in establishing the initial connection to a distance of band. Did someone else has this problem and is there a solution?

    Thank you!

    Thanks a bunch, I went through all the processes of 'Factory Reset' and which certainly did not help. I took your advice and your instructions on return to 1.0.4.28 and it worked like a charm!

    I am now my Surface automatically compressed to a distance of 50 feet or more, through 3 walls on my terrace (as far as I dared so far) no problemo!

    With the latest firmware, I had to be sitting next to the router. The latest firmware is really baaad!

    Thank sagain for your help!

  • BlackBerry Curve 8320 Smartphone T-Mobile system the most recent version for 8GB media card?

    I want to install a 8 GB memory card in my T-Mobile 8320. Should what system I install so it can recognize the larger paper size?

    Thank you.

    BlackBerry Device Software media card size limit

    BlackBerry Device Software 4.2.0 - up to 2 GB

    BlackBerry Device Software 4.2.1 - up to 4 GB

    BlackBerry Device Software 4.2.2 - up to 4 GB

    BlackBerry Device Software 4.3.0 - up to 8 GB

    BlackBerry Device Software 4.5.0 - up to 8 GB

    BlackBerry Device Software 4.5.0.81 and above - up to 16 GB

    BlackBerry Device Software 4.6.0 - up to 32 GB

    http://www.BlackBerry.com/BTSC/search.do?cmd=displayKC&docType=kc&externalId=KB05461&sliceId=SAL_Pub...

  • Application of most recent date...

    Hi all..

    I noticed 2 tables and sub_note and sample data is...
    create table note(note_date date,pmry_id number,sub_id number not null)
    
    insert into note(note_date,pmry_id,sub_id) values('12/30/2008 02:12:52',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/23/2008 10:12:24',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/22/2008 01:12:11',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:56',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/19/2008 01:12:54',282,1)
    insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:56',282,2)
    insert into note(note_date,pmry_id,sub_id) values('12/22/2008 09:12:57',282,2)
    
    create table sub_note(sub_id number not null,sub_name varchar2(100))
    
    insert into sub_note(sub_id,sub_name) values(1,'Product')
    insert into sub_note(sub_id,sub_name) values(2,'Expectations')
    How can select the most recent date of product and the more recent date for the expectations... to join these 2 tables of...

    Thanks in advance...

    Hello

    Use MAX and GROUP BY:

    SELECT       sn.sub_name
    ,       MAX (n.note_date)     AS latest_note_date
    FROM       note          n
    JOIN       sub_note     sn     ON n.sub_id     = sn.sub_id
    WHERE       n.sub_name IN ('Product',     'Expectations')
    GROUP BY  sn.sub_name;
    
  • How to find the most recent record?

    How to find the most recent record?

    Hello

    It is part of our Bill the elements table, retrieved by the following query:

    SELECT movimento, dt_movimento, cd_material,
    cd_tp_operacao, nf, series,
    sole, pr_unitario
    Of itemfat
    WHERE cd_material IN ('722136', '759177', ' 810725', 818848')
    AND cd_tp_operacao ("' 1102 c ' ', ' 2102 C")
    ORDER BY cd_material,
    dt_movimento


    MOVIMENTO DT_MOVIMENTO CD_MATERIAL CD_TP_OPERACAO NF SERIES AS PR_UNITARIO
    2008-03-11 2137625, 722136 2102 1084738 3 120 2 915
    2588890 08/05/2008 722136-2102 1090987 3 120 2,5615
    755522 09/10/2007 759177-2102 101449 1 200 0.6
    701055 03/10/2007 810725-2102 1013865 1 36 10.9
    1588804 20/12/2007 810725 2102 1014182 1 96 10.9
    1305653 03/12/2007 818848-2102 108555 1 240 6.5
    3102134 07/18/2008 818848 2102 109784 1 360 6.5


    Seems that I whant to retrieve only the most recent records for each item, as:

    MOVIMENTO DT_MOVIMENTO CD_MATERIAL CD_TP_OPERACAO NF SERIES AS PR_UNITARIO
    2588890 08/05/2008 722136-2102 1090987 3 120 2,5615
    755522 09/10/2007 759177-2102 101449 1 200 0.6
    1588804 20/12/2007 810725 2102 1014182 1 96 10.9
    3102134 07/18/2008 818848 2102 109784 1 360 6.5


    Can someone help me with a sentece SQL to do?

    Thanks in advance.

    You can certainly do it:

    SELECT   movimento, dt_movimento, cd_material, cd_tp_operacao, nf, serie,
             quantidade, pr_unitario
        FROM itemfat i
       WHERE cd_material IN ('722136', '759177', '810725', '818848')
         AND cd_tp_operacao IN ('1102C', '2102C')
         AND dt_movimento =
                (SELECT MAX (dt_movimento)
                   FROM itemfat d
                  WHERE d.cd_material = i.cd_material
                    AND d.cd_material IN ('722136', '759177', '810725', '818848')
                    AND d.cd_tp_operacao IN ('1102C', '2102C'))
    ORDER BY cd_material, dt_movimento
    

    : p

Maybe you are looking for