Performance of the queries in order to get the most recent price

Happy new year everyone.

I have a table of price in my system that has several awards for each product with the date, the price is entered into force.

I have queries throughout the system to retrieve the most recent actual price for the date of the transaction.

I can find to implement the easiest way is to have a user-defined function to collect the prize.

My problem is that many of my questions have access to large amounts of data (for example, transactions) and my table of prices is also big enough - both have millions of records. Using a Pl/SQL function defined by the user in my query, I get a lot of switching context between SQL and PL/SQL and my questions are not well

Here is an example of code, which simplifies my scenario:

drop table xo_stock_trans;
create table xo_stock_trans (item varchar2(25), trans_date date, quantity number(20,4));
insert into xo_stock_trans values('A',TO_DATE('25-DEC-2014','DD-MON-YYYY'), 4);
insert into xo_stock_trans values('A',TO_DATE('27-DEC-2014','DD-MON-YYYY'), -2);
insert into xo_stock_trans values('A',TO_DATE('28-DEC-2014','DD-MON-YYYY'), 5);
insert into xo_stock_trans values('B',TO_DATE('23-DEC-2014','DD-MON-YYYY'), 20);
insert into xo_stock_trans values('B',TO_DATE('26-DEC-2014','DD-MON-YYYY'), -6);
insert into xo_stock_trans values('B',TO_DATE('29-DEC-2014','DD-MON-YYYY'), 15);
/
-- Generate lots more data
BEGIN
    -- Generate more trans dates
    for r in 1..1000
    LOOP
        insert into xo_stock_trans
        select item, trans_date - r - 7 as  trans_date, ROUND(dbms_random.value(1,50),2) as quantity
        from xo_stock_trans
        where trans_date between TO_DATE('23-DEC-2014','DD-MON-YYYY') AND TO_DATE('29-DEC-2014','DD-MON-YYYY')
          and item in ('A','B');
    END LOOP;
    COMMIT;
    -- generate more items
    for lt in 1..12 
    LOOP
        -- generate C,D, E, items
        INSERT into xo_stock_trans
        SELECT chr(ascii(item)+(lt*2)) as item, trans_date, quantity
        from xo_stock_trans
        where item in ('A','B');
        -- generate A1, A2, B1, B2, etc
        for nm in 1..10
        LOOP
            INSERT INTO xo_stock_trans
            select item || to_char(nm), trans_date, quantity
            from xo_stock_trans
            where length(item) = 1;
        END LOOP;
        COMMIT;
    END LOOP;
    COMMIT;
END;
/
create index xo_stock_trans_ix1 on xo_stock_trans (item);
create index xo_stock_trans_ix2 on xo_stock_trans (trans_date);
exec dbms_stats.gather_table_stats(ownname =>user, tabname => 'XO_STOCK_TRANS' , estimate_percent => 100, degree => dbms_stats.auto_degree, cascade=>true);
/


drop table xo_prices;
create table xo_prices (item varchar2(25), price_date date, gross_price number(20,4), net_price number(20,4), special_price number(20,4) );
insert into xo_prices values ('A', to_date('01-DEC-2014','DD-MON-YYYY'), 10, 8, 6);
insert into xo_prices values ('A', to_date('25-DEC-2014','DD-MON-YYYY'), 9, 8, 6);
insert into xo_prices values ('A', to_date('26-DEC-2014','DD-MON-YYYY'), 7, 6, 4);
insert into xo_prices values ('B', to_date('01-DEC-2014','DD-MON-YYYY'), 5.50, 4.50, 3);
insert into xo_prices values ('B', to_date('25-DEC-2014','DD-MON-YYYY'), 5.00, 4.00, 3);
insert into xo_prices values ('B', to_date('26-DEC-2014','DD-MON-YYYY'), 3.50, 2.50, 2);
/
-- Generate lots more data
BEGIN
    -- Generate more price dates
    for r in 1..1000
    LOOP
        insert into xo_prices
        select item, price_date - r - 7 as  price_date,gross_price, net_price, special_price
        from xo_prices
        where price_date between TO_DATE('23-DEC-2014','DD-MON-YYYY') AND TO_DATE('29-DEC-2014','DD-MON-YYYY')
          and item in ('A','B');
    END LOOP;
    COMMIT;
    -- generate more items
    for lt in 1..12 
    LOOP
        -- generate C,D, E, items
        INSERT into xo_prices
        SELECT chr(ascii(item)+(lt*2)) as item, price_date, gross_price + (lt*2), net_price + (lt*2), special_price + (lt*2)
        from xo_prices
        where item in ('A','B');
        -- generate A1, A2, B1, B2, etc
        for nm in 1..10
        LOOP
            INSERT INTO xo_prices
            select item || to_char(nm), price_date, gross_price, net_price, special_price
            from xo_prices
            where length(item) = 1;
        END LOOP;
        COMMIT;
    END LOOP;
END;
/

create index xo_prices_ix1 on xo_prices (item, price_date);
exec dbms_stats.gather_table_stats(ownname =>user, tabname => 'XO_PRICES' , estimate_percent => 100, degree => dbms_stats.auto_degree, cascade=>true);
/

create or replace function xo_get_price(I_Item in VARCHAR2, I_Date in DATE, i_Price_type IN VARCHAR2) RETURN NUMBER
IS
    -- Function to get most recent effective price prior to the date
    CURSOR c_get_prices(P_Item VARCHAR2, P_Date VARCHAR2)
    IS
    SELECT gross_price, net_price, special_price
    FROM XO_PRICES
    WHERE item = P_Item
     AND price_date <= P_Date
    ORDER BY price_date desc; -- most recent price
    
    l_gross_price NUMBER(20,4);
    l_net_price NUMBER(20,4);
    l_special_price NUMBER(20,4);
BEGIN
    OPEN c_get_prices(I_Item, I_Date);
    FETCH c_get_prices INTO l_gross_price, l_net_price, l_special_price;
    CLOSe c_get_prices;
    
    IF I_Price_Type='GROSS' then return l_gross_price;
    ELSIF I_Price_Type= 'NET' then return l_net_price;
    ELSIF I_Price_Type= 'SPECIAL' then return l_special_price;
    END IF;
END xo_get_price;
/

-- Here is a typical query I am trying to perform
select tr.item, tr.trans_date, tr.quantity
    , xo_get_price(tr.item, tr.trans_date, 'GROSS') as gross_price
    , xo_get_price(tr.item, tr.trans_date, 'NET') as net_price
    , xo_get_price(tr.item, tr.trans_date, 'SPECIAL') as special_price
from xo_stock_trans tr
where tr.trans_date between '01-AUG-2014' and '31-AUG-2014';

I would like to refactor my request so that I do not use the user Pl/SQL functions, but so far I can't get something that works better than the SQL above. For example, the following query is MUCH longer:

select tr.item, tr.trans_date, tr.quantity
    , pr.gross_price
    , pr.net_price
    , pr.special_price
from xo_stock_trans tr
join xo_prices pr on pr.item = tr.item
                and pr.price_date = (select max(pr2.price_date)
                                     from xo_prices pr2
                                     where pr2.item = pr.item
                                       and pr2.price_date <= tr.trans_date
                                     )
where tr.trans_date between '01-AUG-2014' and '31-AUG-2014';

I'm interested to know if anyone has addressed a similar scenario and have managed to write more efficient code.

I looked at the determinism/manual caching of the function, but the article/date combinations are quite unique and therefore he does not benefit from him.

Any suggestion under review - parallelism, analytical, pipeline functions, etc.

Alan

Hi, Alan.

Alan Lawlor wrote:

...

My problem is that many of my questions have access to large amounts of data (for example, transactions) and my table of prices is also big enough - both have millions of records. Using a Pl/SQL function defined by the user in my query, I get a lot of switching context between SQL and PL/SQL and my questions are not well...

You got that right!  User-defined functions can be very practical, but this practice comes with a price.

What version of Oracle are you using?  The Oracle 12, there is a new feature of 'temporal validity' which may help you.

In any version, it will be much faster if you add a new column to the xo_prices table.  You can call this end_date, although it would in fact be the date when some other prices took effect.  You might put DATE' 9999-12-31 in the column end_date for current prices.  You can calculate end_date using the analytical function of LEAD.  Be sure to re-calcluate end_date when you insert new rows into xo_prices, or when you update the dates on existing lines.

Once you have PRICE_DATE and end_date in the XO_PRICES table, you can join this table to get the real price from d by including

AND d > = xo_prices.price_date

AND d< >

in the join condition.

In some situations, especially when you don't have much different (item, dates) combinations, scalar-sub-queries could be faster than joins.

Whatever it is, it participates without PL/SQL, so there is no context switching.

Tags: Database

Similar Questions

  • I uninstalled the old version of Adobe Reader and tried to download the most recent version; However, I get a message indicating that the new version is already installed.  Adobe is not listed as an Application on my computer.

    I was unable to update Adobe Reader in my computer; then I uninstalled the program.  When I tried to download the latest version of Adobe, I received a message stating that the most recent version of Adobe is already installed on my computer. I don't see Adobe on the list of applications on my computer, any suggestions on what to do? Thank you...

    Hi annac88455204,

    Could you please tell me which OS is running on your system?

    You must remove all traces of the previous versions of reader in order to download a new.

    On windows platform, you can try running the cleaning from the indicated link tool:Download Adobe Reader and Acrobat cleaning tool - Adobe Labs.

    Restart the computer and then try to download the new version from the links provided: https://get.adobe.com/reader/enterprise/

    Please let us know if this solves your problem.

    Concerning

    Sarojini

  • 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.

  • 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.

  • How do you get the most recent backup that always has this app on it?

    My 2 years has removed an application in the course of the past week. He regularly plays with my phone, so I have no idea when he managed to do so. I do iCloud backups every night and have this updated app to make backups as well. Is there a way to check the applications included in backups to restore the most recent backup with this app still on it and I hope that the latest data? The only option I can think of right now is to keep remove and restore my phone until I get to a backup with the application, but this seems incredibly long.

    You can see a breakdown of the contents of the backup of the last backup. If you know that it has been deleted some time in the past week, restore a backup from a week ago. If there was some new data on the phone since then you do not want to lose, then Yes, you would probably try the trial and error method.

  • Windows 7 photo order oldest to the most recent

    Unable to display my photos in chronological order taken. They default to the most recent date but not on the closest date

    You can do a right click on the background of the white paper and click Sort by and use ascending or descending.

  • Get the most recent version number of CC Applications

    Hello

    is there a way to get the most recent version of all/some products CC numbers? We want to make a list with the latest versions. On the website of adobe, not found any source, where you can easily get the version numbers of products. The creative Application of cloud is perhaps not the best solution to check versions. This should be done by a script automaticality every week/month. Is there any URL/downloadable file to get the latest versions?

    concerning

    Dominic

    is there a way to get the most recent version of all/some products CC numbers?

    I don't know, location of a resource on the Adobe website that provides this information in one alone.

    The closest I know is to

    2015 all updates of Adobe CC: Direct for Windows download links | ProDesignTools

  • I think ordering the fotography subscription, but the version of photoshop is always the most recent?

    Hey guys

    I think ordering the fotography subscription, but the version of photoshop is always the most recent?

    Hi Arnoh,

    Being a member of Creative cloud photography Plan, you will have access to the most recent version and the update of Photoshop and lightroom.

    Kind regards

    Tanuj

  • I always get requests to update on my office home page. After the most recent, most of my quick start icons are badges of adobe. Except a few functions are not open. When I right click on Firefox (for example) it says 'READ' instead of 'OPEN' and t

    I always get requests to update on my office home page. After the most recent, most of my quick start icons are badges of adobe. Except a few functions are not open. When I right click on Firefox (for example) it says 'READ' rather than 'OPEN' and then displays the Adobe error box. The only other answer I received (from Ask.com) is that the update was a virus. I'm not computor savy and my pc is quite old. I just want to come an hour before this recent action, but I can't open Norton power eraser or even the ability of the computer to return to an earlier point in time to cancel the action. Each of these attempts of task appears Adobe error box. I am currently showing Adobe Reader X 10,0

    Hi deanrlh,

    I apologize for the inconvenience caused. Please follow the steps in the below article mentioned: Application, file icons change in Acrobat/Reader icon

    Thank you

    Abhishek

  • How can I get the most recent copy of the SAS 70 of EchoSign reports?

    How can I get the most recent copy of the SAS 70 of EchoSign reports?

    Hello Emilyp96102994,

    I recommend to open a ticket with the support that they can provide more detailed information about:

    Support | services of Adobe eSign

    -Usman

  • We use Adobe Acrobat 10. When I try to download the most recent update, I get the message error 1608 download failed. How can I fix it.

    We use Adobe Acrobat 10. When I try to download the most recent update, I get the message error 1608 download failed. How can I fix it?

    Uninstall acrobat, clean (if windows os), Download Adobe Reader and Acrobat cleaning - Adobe Labs tool , and then reinstall.

  • Sometimes, I get a notice from a site that Firefox needs an update. When I go into FIrefox, it says that I use the most recent version. What is happening?

    I wonder if these sites are trying to make me download malware or virus. If I go to the Firefox site and it says that I use the most recent version, I think Mozilla tells me and wonder "why a site told me that I have to update? I hope only that Mozilla and not blindly download something without studying. Am I paranoid?

    No, it's a scam which is the link to the site, mozilla does not use a site to ask you to update, it uses an automatic update.

    You can report it here

  • Path of the most recent added file using applescript

    I use appleScript Automator to download new pictures on my Instagram.

    The script trigger when the new file is added to a folder "updates".

    Open the app (work)

    activate an application "Uploader HD for Instagram"

    delay 0.5

    Tell application "system events".

    say "Uploader HD for Instagram" processes

    Click on the menu "open...". "the menu 1 menu bar item 'File' from the menu bar 1

    tell the end

    tell the end

    Activate the "go in the folder" CMD + SHIFT + G

    Tell application "system events".

    delay 1

    combination of keys 'G' using {control down, moving down}

    delay 1

    tell the end

    This is the problem... I "Don't KNOW" the name of the most recent added the file and there are a lot of files on the folder... So I can't use the full path of the file on the 'go in the folder ".

    Tell application "system events".

    combination of keys "/ Users/HazaelDiaz/Google Drive/IFTTT/Instagram/update/2016 / '.

    delay of 0.1

    strike back

    delay of 0.1

    strike back

    tell the end

    Since I trigger the 'applescrip' using the 'Workflow folder action... " Is it possible that I can get the value or the path of the new file included?

    I found a code that renames all the files from 0 to xxx folder action, but the new included file is always the last of them on digital process... is possible to rename the files and give the new file name "update1.jpg" first?

    Also I can order "Go to folder" action must seek that specify the file: 'update1.jpg. '

    This is the script name change: (BTW, these scripts always ask me to select folder... and what I want is to be automated out of my interaction with but do not know how to change so it will always use the "updates" folder

    Tell application "Finder".

    a in each file of the entire contents of the value (choose the folder)

    Repeat with aa in one

    the file_name my MakeBase (aa AsString) value

    If file_name is not 'JUMP' then

    count_er Set 1

    the value all_files (all files in aa)

    Repeat the operation with ff in all_files

    the name value of ff ((texte-3-1 par le biais de ("000" & (count_er as string))) & "." & (name extension for ff))

    Set count_er to count_er + 1

    end repeat

    end if

    end repeat

    tell the end

    to MakeBase (txt)

    the value astid delimiters to point to the text of the AppleScript

    the text value of the point AppleScript delimiters «:»

    the value for each item of text txt new_Name_Raw

    the text value of point AppleScript delimiters to "_".

    the value final_Name for each item in new_Name_Raw text text

    the text value of the point AppleScript astid delimiters

    If length > 251 of final_Name then set final_Name on 'SKIP' - will be more than 4 characters for counter

    return final_Name

    end MakeBase

    Any help will be much appreciated.

    Thanks /.

    What version of Mac OS X are you running?

  • Firefox continues to show that I need high-grade firefox but I have the most recent, how to stop it

    Popup message that I need to high-grade, fire fox, already have the most recent in a (No 26). Have uninstalled and reinstalled and still get the message that I need to up grade, have windows 7.

    Whenever you get a message / popup that software / files must be updated.

    DO NOT USE ONE OF THE LINKS PROVIDED.

    If this can be a legitimate message, could also be a Virus or Malware.
    No matter when you want or need to check updates.
    Go to the website of the real owner of the program in question.
    For example, for Firefox, go to Mozilla.org
    or Firefox in any language.

  • My firefox does not work llook like the most recent version. I downloaded it on my aunts comp and in the corner upper lft, there's a firefox orange box but still just mine has firefox symbol.

    I had firefox for over a year and I recently installed on my computer of aunts. When I've done in the upper left corner, there was an orange box that says firefox on it. I have recently installed on my computer and it's always the same, as I had before. (Just the symbol of firefox) How can I get the latest version? It does not say I have the 6.2 or what is the most recent. Thank you in advance for the quick response to my question.

                                        Amy Vitko
    

    The current stable version is Firefox 6. 0.2

    https://support.Mozilla.com/en-us/KB/how-do-i-get-Firefox-button
    Why can't I see it?

    To make Firefox look like other programs in Windows XP, the menu bar is displayed instead of the Firefox button, while under Windows Vista and Windows 7, the button is displayed by default in Firefox.

Maybe you are looking for