Several updates on the same Table

Hello

I need to update the same Table (T1) but to filter for different conditions as below.
and I have a set of filter conditions 50 and update the same table.

Is it possible to get in the single update statement?

BEGIN
UPDATE T1
SET PTA_CLM_CNT = v_PTA_CLM_CNT__77,
PTB_CLM_CNT = v_PTB_CLM_CNT__77
WHERE run_dt = v_in_parm_dt
AND state_code = '77';
EXCEPTION
WHEN NO_DATA_FOUND THEN
null;
WHILE OTHERS THEN
v_error_cd: = SQLCODE;
v_error_msg: = SUBSTR (SQLERRM, 1, 200);
v_curr_record: = 'sum_bene_state_updt_77 ' | v_in_parm_dt;
create_error_log ('_sum_cnts', v_error_cd, v_error_msg, v_curr_record);
END;

BEGIN
UPDATE T1
SET PTA_CLM_CNT_ = v_PTA_CLM_CNT__78,
PTB_CLM_CNT_ = v_PTB_CLM_CNT__78
WHERE run_dt = v_in_parm_dt
AND state_code = '78';
EXCEPTION
WHEN NO_DATA_FOUND THEN
null;
WHILE OTHERS THEN
v_error_cd: = SQLCODE;
v_error_msg: = SUBSTR (SQLERRM, 1, 200);
v_curr_record: = 'sum_bene_state_updt_78 ' | v_in_parm_dt;
create_error_log ('sum_cnts', v_error_cd, v_error_msg, v_curr_record);
END;

Thanks in advance

May be trying to use DECODE

UPDATE T1
   SET PTA_CLM_CNT = DECODE(state_code,77,v_PTA_CLM_CNT_77,78,v_PTA_CLM_CNT_78)
       PTB_CLM_CNT = DECODE(state_code,77,v_PTB_CLM_CNT_77,78,v_PTB_CLM_CNT_78)
 WHERE run_dt = v_in_parm_dt;

Tags: Database

Similar Questions

  • Update of several rows of the same table using trigger

    Hello

    I have the following table

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

    CREATE TABLE ATT_PERMISSIONS
    (
    DATE OF PRMONTHYR,
    EMPIDNUMBER (10)DEFAULT VALUE 0,
    FROMDATETIMEDATE,
    TODMTFDATETIMEDATE,
    NUMBER OF PERMMINS (3),

    SSLINASTRETCH NUMBER (3).

    PERMATTINELIGIBLENUMBER (1)DEFAULT VALUE 0
    );

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

    I want to update the column PERMATTINELIGIBLE in the same table when each line is inserted.

    I created following trigger for that

    CREATE OR REPLACE TRIGGER SSL_AFTER_UPDATE AFTER UPDATE ON ATT_PERMISSIONS

    FOR EACH LINE

    BEGIN

    Update ATT_PERMISSIONS set PERMATTINELIGIBLE =

    (

    SELECT THE CHECK BOX

    WHEN PERMMINS < = 60

    or

    (

    PERMMINS < = SSLINASTRETCH

    AND

    COUNT (CASE WHEN PERMMINS = 0 THEN NULL OTHERWISE 1 END)

    COURSES (PARTITION BY empid, prmonthyr) < = 1

    )

    THEN 1

    0 OTHERWISE

    END

    FROM ATT_PERMISSIONS where prmonthyr =:new.prmonthyr, empid =:new.empid

    ) where prmonthyr =:new.prmonthyr, empid =:new.empid;

    END;

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

    That is to say.

    When a row is inserted the PERMATTINELIGIBLE of all records for this employee for the month is recalculated.

    There would be only two or three records for an employee for a month.

    PERMMINS is the number of minutes to use as short leave.

    If it is less than 60 is eligible for the bonus to attendance for this employee.

    If this isn't normally the date is not eligible for the attendance for this employee premium.

    but an exception is that if a short leaves of DISP employee allowed a month (IE. ( SSLINASTRETCH ) in a straight line, IE. one day, that day is eligible for the bonus of presence.

    That is to say. Why the number of short leaves in a month is taken. If it's one and done minutes use is lower to SSLINASTRETCH, then the day is eligible for the attendance bonus.

    But when I try to create the trigger I get error, PL/SQL: ORA-00907: missing a right parenthesis.

    Help, please

    I use oracle 10g

    I want to update the column PERMATTINELIGIBLE in the same table, when each row is inserted.

    No - you do NOT want to do in a trigger.

    You cannot query the same table that the trigger is activated on. -C' is a MUTANT and you will get an exception.

    When a row is inserted is recalculated to the PERMATTINELIGIBLE of all the records for that employee for that month.

    There would be only two or three records for an employee for a month.

    PERMMINS is the number of minutes to use as short leave.

    If it is less than 60 is eligible for the bonus to attendance for this employee.

    If is not normally the day is not eligible for the premium of attendance for this employee.

    but an exception is that if a short leaves of DISP employee allowed a month (IE. SSLINASTRETCH) in a straight line, IE. one day, that day is eligible for the bonus of presence.

    That is to say. Why the number of short leaves in a month is taken. If it's one and done minutes use is less than SSLINASTRETCH, then the day is eligible for the bonus of presence.

    But when I try to create the trigger I get error, PL/SQL: ORA-00907: missing a right parenthesis.

    You can not do in a trigger. Even if correct you this error of syntax, you will get the exception that I mentioned above.

    Oracle is a multi-user system. Other users can modify the same table that you use.

    So even if you could try to interview "all the records for this employee" some of them may be locked if other users access them. Also, an insert statement could try to insert two rows for an employee and the trigger could not have seen the other lines still.

    If you want to work with data SETS (all records for an employee), you must write the PL/SQL code that LOCKS all lines updated to prevent others to interfere.

    Then you make your operations but NOT in a trigger. Perform inserts and then use an UPDATE query to set this value.

    Then VALIDATE to unlock the lines.

  • UPDATE on the same table in the sub query

    DB version: 11.2

    We have a table called SHP_GC_TRACK, which has about 8 million records with partitions. In the below UPDATE, it updates a column based on the SELECT on the same table in a subquery.
    UPDATE shp_gc_track a
       SET f_tran_proc  = 'Y'
     WHERE last_update_date <
              (SELECT MAX (last_update_date)
                 FROM shp_gc_track b
                WHERE a.shp_trx_rowid = b.shp_trx_rowid
                  AND a.c_shp_inst = b.c_shp_inst
                  AND a.f_tran_proc  = b.f_tran_proc 
                  AND b.f_ltr_received = 'D'
                  AND f_rec_code IN ('G', 'W')
                  AND b.f_rec_status = 'B'
                  AND b.c_shp_inst = :b1
                  )
       AND a.c_shp_inst = :b1
       AND a.f_ltr_received = 'D'             -----------------> part of composite index
       AND a.f_tran_proc  = 'N'              -----------------> part of composite index
       AND a.f_rec_code IN ('G', 'W')      --------------> part of composite index  
       AND a.f_rec_status = 'B';              -----------------> part of composite index  
    This UPDATE takes a long time to run and sometimes get hung up.

    We have a composite index on four columns f_ltr_received, f_rec_code, f_rec_status and f_tran_proc. Explain the plan shows that this composite index is used.



    Any way to rewrite this query or suggestion?

    Steve_74 wrote:
    DB version: 11.2

    We have a table called SHP_GC_TRACK, which has about 8 million records with partitions. In the below UPDATE, it updates a column based on the SELECT on the same table in a subquery.

    UPDATE shp_gc_track a
    SET f_tran_proc  = 'Y'
    WHERE last_update_date <
    (SELECT MAX (last_update_date)
    FROM shp_gc_track b
    WHERE a.shp_trx_rowid = b.shp_trx_rowid
    AND a.c_shp_inst = b.c_shp_inst
    AND a.f_tran_proc  = b.f_tran_proc
    AND b.f_ltr_received = 'D'
    AND f_rec_code IN ('G', 'W')
    AND b.f_rec_status = 'B'
    AND b.c_shp_inst = :b1
    )
    AND a.c_shp_inst = :b1
    AND a.f_ltr_received = 'D'             -----------------> part of composite index
    AND a.f_tran_proc  = 'N'              -----------------> part of composite index
    AND a.f_rec_code IN ('G', 'W')      --------------> part of composite index
    AND a.f_rec_status = 'B';              -----------------> part of composite index  
    

    This UPDATE takes a long time to run and sometimes get hung up.

    We have a composite index on four columns f_ltr_received, f_rec_code, f_rec_status and f_tran_proc. Explain the plan shows that this composite index is used.

    Any way to rewrite this query or suggestion?

    Setting updates with subqueries may be difficult: (.) Unfortunately my suggestions below are of the try-it-and-see-what-happens variety - nothing of certain

    First of all, check the index. Is it bitmap or tree? If the tree to see if the more restrictive columns are listed first - this can help with effectiveness of b-tree indexes. Also if the tree a composite bitmap for columns with lots of repeat values instead could help

    Its a correlated subquery so that you cannot run just the subquery first put the result in a scalar varaiable and using the variable in the SQL instead. You can try putting the keys w/join subuqery results in a TWG first to use TWG in SQL to see if I/O is reduced together during these two operations.

    You have the license for the parallel query option? Using parallel DML (this must be activated manually) can help. Check the documentation of the ALTER SESSION command to do so. In addition, the PARALLEL_INDEX() indicator could help

    Display the SQL execution plan

  • Compare several records in the same table

    Hello, I m writing a bat file so I can export information that I question.

    I have an automatic integration which checks from time to time if there is no new client´s and generates a trigger.
    If an error levonorgestrol I the process is repeated until the client is located in the database.
    I can't create tables or change the structure.


    My problem is that I need to compare the record more updated with the CLIENT_ID field
    Let me give you an example:


    Table A

    ERROR_MESSAGE CREATEDUSERID CLIENT_ID
    0 success 01/01/2009
    1 error 01/01/2009
    2 success 01/01/2009
    1 success 01/02/2009
    3 success 01/02/2009
    4 error 01/02/2009

    I need to compare "1" client created on 01/01/2009 this error gived with new records to see if there's success and my
    query should only return the client_ID '4' and export with sqlplus

    Could you please help me?

    Hello

    It works very well with my data.
    What data do you use? After a few lines of sample data (CREATE TABLE AS executable... or INSERT... statements are best) that give you wrong results.

    Make sure that everything is spelled correctly.
    For example, roughly halfway through the query, you say

    and io.status = 'Erro' 
    

    and at the end you say

    having max(decode(io.status, 'Error', 1, 2))  ...
    

    That is the same ("Error" or "Error") in both places?

  • Cannot uncheck several updates in the same category.

    I would have thought by now that all changes (no doubt excellent) Windows Update for Vista, that something would have been made with respect to the Active-X for XP.

    They can? I guess.

    Will they? I doubt it since WinXP SP3 is in Extended Support.

    ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • update to column values (false) in a copy of the same table with the correct values

    Database is 10gr 2 - had a situation last night where someone changed inadvertently values of column on a couple of hundred thousand records with an incorrect value first thing in the morning and never let me know later in the day. My undo retention was not large enough to create a copy of the table as it was 7 hours comes back with a "insert in table_2 select * from table_1 to timestamp...» "query, so I restored the backup previous nights to another machine and it picked up at 07:00 (just before the hour, he made the change), created a dblink since the production database and created a copy of the table of the restored database.

    My first thought was to simply update the table of production with the correct values of the correct copy, using something like this:


    Update mnt.workorders
    Set approvalstat = (select b.approvalstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi)
    where exists (select *)
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi)

    It wasn't the exact syntax, but you get the idea, I wanted to put the incorrect values in x columns in the tables of production with the correct values of the copy of the table of the restored backup. Anyway, it was (or seem to) works, but I look at the process through OEM it was estimated 100 + hours with full table scans, so I killed him. I found myself just inserting (copy) the lines added to the production since the table copy by doing a select statement of the production table where < col_with_datestamp > is > = 07:00, truncate the table of production, then re insert the rows from now to correct the copy.

    Do a post-mortem today, I replay the scenario on the copy that I restored, trying to figure out a cleaner, a quicker way to do it, if the need arise again. I went and randomly changed some values in a column number (called "comappstat") in a copy of the table of production, and then thought that I would try the following resets the values of the correct table:

    Update (select a.comappstat, b.comappstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi - this is a PK column
    and a.comappstat! = b.comappstat)
    Set b.comappstat = a.comappstat

    Although I thought that the syntax is correct, I get an "ORA-00904: 'A'. '. ' COMAPPSTAT': invalid identifier ' to run this, I was trying to guess where the syntax was wrong here, then thought that perhaps having the subquery returns a single line would be cleaner and faster anyway, so I gave up on that and instead tried this:

    Update mnt.workorders_copy
    Set comappstat = (select distinct)
    a.comappstat
    mnt.workorders a, mnt.workorders_copy b
    where a.workordersoi = b.workordersoi
    and a.comappstat! = b.comappstat)
    where a.comappstat! = b.comappstat
    and a.workordersoi = b.workordersoi

    The subquery executed on its own returns a single value 9, which is the correct value of the column in the table of the prod, and I want to replace the incorrect a '12' (I've updated the copy to change the value of the column comappstat to 12 everywhere where it was 9) However when I run the query again I get this error :

    ERROR on line 8:
    ORA-00904: "B". "" WORKORDERSOI ": invalid identifier

    First of all, I don't see why the update statement does not work (it's probably obvious, but I'm not)

    Secondly, it is the best approach for updating a column (or columns) that are incorrect, with the columns in the same table which are correct, or is there a better way?

    I would sooner update the table rather than delete or truncate then re insert, as it was a trigger for insert/update I had to disable it on the notice re and truncate the table unusable a demand so I was re insert.

    Thank you

    Hello

    First of all, after post 79, you need to know how to format your code.

    Your last request reads as follows:

    UPDATE
      mnt.workorders_copy
    SET
      comappstat =
      (
        SELECT DISTINCT
          a.comappstat
        FROM
          mnt.workorders a
        , mnt.workorders_copy b
        WHERE
          a.workordersoi    = b.workordersoi
          AND a.comappstat != b.comappstat
      )
    WHERE
      a.comappstat      != b.comappstat
      AND a.workordersoi = b.workordersoi
    

    This will not work for several reasons:
    The sub query allows you to define a and b and outside the breakets you can't refer to a or b.
    There is no link between the mnt.workorders_copy and the the update and the request of void.

    If you do this you should have something like this:

    UPDATE
      mnt.workorders     A      -- THIS IS THE TABLE YOU WANT TO UPDATE
    SET
      A.comappstat =
      (
        SELECT
          B.comappstat
        FROM
          mnt.workorders_copy B   -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      )
    WHERE
      EXISTS
      (
        SELECT
          B.comappstat
        FROM
          mnt.workorders_copy B
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      )
    

    Speed is not so good that you run the query to sub for each row in mnt.workorders
    Note it is condition in where. You need other wise, you will update the unchanged to null values.

    I wouold do it like this:

    UPDATE
      (
        SELECT
          A.workordersoi
          ,A.comappstat
          ,B.comappstat           comappstat_OLD
    
        FROM
          mnt.workorders        A      -- THIS IS THE TABLE YOU WANT TO UPDATE
          ,mnt.workorders_copy  B      -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES
    
        WHERE
          a.workordersoi    = b.workordersoi      -- THIS MUST BE THE KEY
          AND a.comappstat != b.comappstat
      ) C
    
    SET
      C.comappstat = comappstat_OLD
    ;
    

    This way you can test the subquery first and know exectly what will be updated.
    This was not a sub query that is executed for each line preformance should be better.

    Kind regards

    Peter

  • Why Windows asks me to install the same updates several times. Often several times the same updates and often several times in the same day?

    I install security updates and important. Sometimes in the same day, I wonder to install the same updates. When I check the history I see that they are already installed. This can happen several times in the same day.

    Troubleshooting Windows Update or Microsoft Update when you are repeatedly offered an update

    UTC/GMT is 00:34 Sunday, March 11, 2012

  • Updated with the values in the same table, for other records corresponding to conditions

    Hi Experts,

    Sorry do not provide the structure of the table (it is a simple structure)

    I have a requirement where I need to update the columns of a table based on the same table with some match empid and date values. If the date and empid match so I have these values to any other folder and update of one who is not having details of Office . I need the Update query

    Before the update my array of values is as below

    Sort_num Emp_id Bureau start_date

    1 101 AUS 01/01/2013
    2 101 01/01/2013
    3 101 15/01/2013
    4 103 USA 01/05/2013
    5 103 01/01/2013
    6 103 05/01/2013
    7 104 FRA 01/10/2013
    8 104 10/01/2013
    9 104 01/01/2013

    After update my table should be as below

    Sort_num Emp_id Bureau start_date

    1 101 AUS 01/01/2013
    2 101 AUS 01/01/2013
    3 101 15/01/2013
    4 103 USA 01/05/2013
    5 103 01/01/2013
    6 103 USA 01/05/2013
    7 104 FRA 01/10/2013
    8 104 FRA 01/10/2013
    9 104 01/01/2013

    Thanks in advance

    I don't have the time to create the table with the data, but basically, you should be able to code the following text

    update one table

    Office set = (select desktop in table b where b.emp_id = a.emp_id)

    and b.start_date = a.start_date

    and b.office is not null

    )

    where is ([as well as overall query])

    and a.office is null

    In my opinion, who will do the trick.

    HTH - Mark D Powell.

  • How to update columns with the value of other lines in the same table

    Hello

    I use Oracle 11.2, I'd use SQL statements to update a column based on values in other rows in the same table. Here are the details:

    create table TB_test (number 4 myId, crtTs date, date of MDPU);

    insert into tb_test (1, to_date ('20110101', 'YYYYMMDD'), null);
    insert into tb_test (1, to_date ('20110201', 'YYYYMMDD'), null);
    insert into tb_test (1, to_date ('20110301', 'YYYYMMDD'), null);
    insert into tb_test (2, to_date ('20110901', 'YYYYMMDD'), null);
    insert into tb_test (2, to_date ('20110902', 'YYYYMMDD'), null);

    After you run the SQL code, I would like to have the following result:

    1, 20110101, 20110201
    1, 20110201, 20110301
    1, 20110301, null
    2, 20110901, 20110902
    2, 20110902, null

    Thanks for your suggestion.

    I guess you need this, otherwise please explain logic correctly:

    SQL> merge into tb_test t
      2  using (
      3    select rowid as rid
      4         , lead(crtts) over(partition by myid order by crtts) as updts
      5    from tb_test
      6  ) v
      7  on (t.rowid = v.rid)
      8  when matched then update
      9   set t.updts = v.updts
     10  ;
    
    5 rows merged.
    
    SQL> select * from tb_test order by 1,2;
    
          MYID CRTTS     UPDTS
    ---------- --------- ---------
             1 01-JAN-11 01-FEB-11
             1 01-FEB-11 01-MAR-11
             1 01-MAR-11
             2 01-SEP-11 02-SEP-11
             2 02-SEP-11
    
  • Update lines with the info from the other rows in the same Table.

    I'm trying to update the lines with the information of the same table. The table is loaded with information from a report that runs and there must be a new entry every month, but I would like to bring some of the info from the last month. This statement below works but updates all rows in the new load table and in my test case, I only did a few game only like 5 files need to get updates. It is an example of what I'm trying to do. If I add this (C2. COL_INVC_ID = C1. COL_INVC_ID) until the last "* where *" statement get an invalid identifier for 'C2 '. COL_INVC_ID ". So what I'm doing wrong here? How can I update only the lines where also in recent months run?

    Thanks in advance for any help!

    ------------
    Update OpenIssues OI1
    Together (OI1. NUM, OI1. Status, OI1. Code, OI1. LastModifiedDate) =
    (Select ios2. NUM, ios2. Status, ios2. Code, ios2. LastModifiedDate
    Of OpenIssues ios2
    Where OI2.num = OI1.num and ios2. TableLoadDate = TO_DATE (January 31, 2012 00:00:00 ',' ' the HH24: MI: SS DD/MM/YYYY)
    )
    Where and OI1. TableLoadDate = TO_DATE (February 29, 2012 00:00:00 ',' ' the HH24: MI: SS DD/MM/YYYY)
    ------------


    SQLMe

    As Frank suggested merger is much effective here, go...

      create table  temp
    as(
    select 1 eno, 1 amt , sysdate load_date from dual union all
    select 1 eno, 2 amt , add_months(sysdate,1) load_date from dual union all
    select 2 eno, 1 amt , sysdate load_date from dual union all
    select 2 eno, 2 amt , add_months(sysdate,1) load_date from dual
    );
    
    merge into temp t
    using (select eno, amt, load_date
             from temp
            where trunc(Load_Date) = TO_DATE('05/30/2012', 'MM/DD/YYYY')) s
    on ((s.eno = t.eno) and trunc(t.Load_Date) = TO_DATE('06/30/2012', 'MM/DD/YYYY'))
    when matched then
      update set t.amt = s.amt;
    commit;
    
    select * from temp;
    
  • Several blocks of the same canvas and window update

    Hi all

    I want to update several blocks from the same canvas and the window. I also want to find an alert before saving the data. Based on the current record, I want to update only
    data in the record.

    Can you help me anyone in this regard.

    Arif

    You must write the validation key trigger to the block level

    I don't think so. As it is not possible to hire only a single block, what would be the use of a KEY VALIDATION trigger at the level of the block? The only effect would be that the shape has according to different where the cursor is positioned.

    If you want the dynamic Blockname (and all blocks of share the same fields that you are filling), you can do something like

    if show_alert('ALERT_TO_VERIFY')=alert_button1 then
      COPY('3', :SYSTEM.TRIGGER_BLOCK || '.REC_STATUS');
      COPY('P', :SYSTEM.TRIGGER_BLOCK || '.TASK_STATUS');
      COPY('P', :SYSTEM.TRIGGER_BLOCK || '.PERMISSION_UPDATED');
      commit_form;
      execute_query;
    end if;
    

    BTW... Why is - that update you the block after commit?

  • Update the same column in the same table

    Hello

    How do update you a records of column in the same table?

    I have purchase_order of the table. Consists of column ID, color, Purchase_No, Sub purchase.


    < pre >

    Create table Purchase_Order)
    Identification number,
    color varchar2 (10),
    purchase_No varchar2 (5).
    purchase_sub varchar2 (2));
    < / pre >

    < pre >

    ID color Purchase_No purchase Sub
    6416 S1406 PURPLE 3
    6415 S1406 GREEN 2
    6414 S1406 GREEN 1
    6419 S1406 3
    6417 S1406 1
    6418 S1406 2

    < pre >

    6 unique ID records is in the same site. But 2 ID will be confined to a purchase_sub.

    For example

    6416,6419 purchase_no S1406 but has the same purchase_sub who need 3.I 6419 color "Purple".

    Expected results:
    < pre >

    ID color Purchase_No purchase Sub
    6416 S1406 PURPLE 3
    6415 S1406 GREEN 2
    6414 S1406 GREEN 1
    6419 S1406 PURPLE 3
    6417 S1406 GREEN 1
    6418 S1406 GREEN 2

    < / pre >

    Thank you!

    Published by: CrackerJack on May 4, 2009 15:04

    Hello

    Try this,

    UPDATE Purchase_Order a
       SET a.Colour = (SELECT colour
                         FROM Purchase_Order b
                        WHERE a.Purchase_Sub = b.Purchase_Sub
                          AND b.colour Is Not Null)
     WHERE a.Colour Is Null
    

    Kind regards
    Christian Balz

  • Safari address bar showing several addresses at the same time

    Anyone else having problems with the address bar. No work to present frequently visited sites and and after visiting the sites manually or via Favorites addresses are crushed between them (showing several addresses at the same time).

    I have the same problem since this morning, after the EL CAPITAN update

  • Windows update - reappear the same updates

    I have Windows 7 Pro. During the last three months updates continued to appear. I downloaded and installed several times. They appear in my update as a success story, but then when the auto update tuns, the same three will appear again. Three updates are:

    • Update for Windows 7 for x 64-based systems (KB3068708)
    • Update for Windows 7 for x 64-based systems (KB3035583)
    • Update security for Windows 7 for x 64-based systems (KB3046269)

    Anyone knows what is the cause?

    The first two in your post have a goal - to 'upgrade' from your computer to Windows 10.  If you don't want Windows 10, there is no need them for sure.

    Change your Windows Update settings for EVER, and this doesn't continue to happen.

    As for the third: https://support.microsoft.com/en-us/kb/2509997

  • comparing string values in the same table

    I have a table with ID (14 digit string values) starting with "A". Ex: A21849B1020792. There may be a different ID with the same substring 'B1020792' in the same table, example: A12349B1020792. If this happens, the ID of the last creation date of must be returned in the result. In other words, comparison is done on the same table. "In the example provided, say A12349B1020792 has the date of 1 January 2015 'and A21849B1020792 has date February 1, 2015", since A21849B1020792 has the most recent date, the result must contain only A21849B1020792.

    ID create_date

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

    A21849B1020792 02/01/2015

    A12349 B1020792 01/01/2015

    A12345B1234567 01/03/2015      

    A43567B1234567 01/04/2015      


    Here's the query I used:

    substr (a.id, 7) select sc, max (a.create_date) cd1

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A12349B1020792', 'A21849B1020792','A12345B1234567 ','A43567B1234567')

    Group of substr (a.id, 7);

    Result:

    ---------

    sc                    cd1

    ---                    ------

    B1020792 02/01/2015

    B1234567 04/01/2015

    There is one thing that I'm not able to do with my request, that is, be able to get real IDs list and not list of substrings. If I added a.id column in the select clause and the group by clause, the query includes both by substr (a.id, 7) and a.id and as a result, the query returns four lines as below:

    substr (a.id, 7) select sc, max (a.create_date) cd1, a.id ID

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A12349B1020792', 'A21849B1020792','A12345B1234567 ','A43567B1234567')

    Group by substr (a.id, 7), a.id.

    Result:

    ---------

    sc                    cd1                      ID

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

    01/01/2015 A12349B1020792 B1020792

    B1020792 01/02/2015 A21849B1020792

    B1234567 01/03/2015 A12345B1234567

    B1234567 01/04/2015 A43567B1234567


    My goal is to retrieve a list of all the unique identifiers that have the later dates.


    ID:

    ---

    A21849B1020792

    A43567B1234567


    Thanks for your time in advance!

    Hello

    user11951344 wrote:

    I have a table with ID (14 digit string values) starting with "A". Ex: A21849B1020792. There may be a different ID with the same substring "B1020792" in the same table, example: A12349B1020792. If this is the case, the ID of the last creation date must be returned in the result. In other words, comparison is done on the same table. "In the example provided, say A12349B1020792 updated 1 January 2015 ' and A21849B1020792 a date February 1, 2015", as A21849B1020792 has the most recent date, the result should contain only the A21849B1020792.

    ID create_date

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

    A21849B1020792 02/01/2015

    A12349B1020792 01/01/2015

    A12345B1234567 03/01/2015

    A43567B1234567 01/04/2015

    Here's the query I used:

    substr (a.id, 7) select sc, max (a.create_date) cd1

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A21849B1020792', 'A12345B1234567', 'A12349B1020792', 'A43567B1234567')

    Group of substr (a.id, 7);

    Result:

    ---------

    sc                    cd1

    ---                    ------

    B1020792 02/01/2015

    B1234567 01/04/2015

    There is one thing that I am not able to do with my request, that is, the ability to retrieve the list of IDs real and not a list of substrings. If I added a.id column in the select clause and the group by clause, the query groups according to the two substr (a.id, 7) and a.id and as a result, the query returns four lines as below:

    substr (a.id, 7) select sc, max (a.create_date) cd1, a.id ID

    of table a, table b

    where a.id! = b.id

    and substr (a.id, 7) = substr (b.id, 7)

    and a.id like 'A %' and b.id like 'A %' / * (I used a % because I am interested only IDs that begin with A) * /.

    and a.id ('A21849B1020792', 'A12345B1234567', 'A12349B1020792', 'A43567B1234567')

    Group by substr (a.id, 7), a.id.

    Result:

    ---------

    sc                    cd1                      ID

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

    B1020792 01/01/2015 A12349B1020792

    B1020792 02/01/2015 A21849B1020792

    B1234567 03/01/2015 A12345B1234567

    B1234567 01/04/2015 A43567B1234567

    My goal is to retrieve a list of all the unique identifiers that have the later dates.

    ID:

    ---

    A21849B1020792

    A43567B1234567

    Thanks for your time in advance!

    If it makes sense to treat the first 6 characters of the ID separately from the rest of the id in this problem, maybe it makes sense to store those two parts of the id in two different columns.  Relational databases work best when each column of each row contains 1 single piece of data (at most).  It is so fundamental to the design of table that he called the first normal form.

    Given that the two parts are stored in column 1, so you can something like this Request Top - N:

    WITH got_r_num AS

    (

    SELECT r.id

    r.create_date AS cd1

    , RANK () OVER (PARTITION OF SUBSTR (r.id, 7))

    ORDER BY r.create_date DESC

    ) AS r_num

    FROM table_x g - g for data values

    JOIN table_x r - r for related values

    ON SUBSTR (r.id, 7) = SUBSTR (g.id, 7)

    WHERE g.id IN ('A12349B1020792'

    , "A21849B1020792".

    , "A12345B1234567".

    , "A43567B1234567".

    )

    - AND g.id LIKE 'A %' - if necessary.   The above condition ensures already g.id start with "A".

    AND r.id LIKE 'a % '.

    )

    SELECT id, create_date

    OF got_r_num

    WHERE r_num = 1

    ;

    If you would care to post CREATE TABLE and INSERT instructions for the sample data, and then I could test this.

Maybe you are looking for