I'm running it on Oracle 11G. I am trying to use columns in table 1 to use values in TABLE2.CLASSNAME. . The keys used to join TABLE1.T1ID = TABLE2.T2ID TABLE2 can have multiple CLASSNAME values for the same ID.
TABLE1:
TID - identifier LOADDT - all records were loaded
/ Pre >
TABLE2:
T2 ID - Identifier LOADDT - Date All records were loaded - A date when student was enrolled in the class. At the latest date, he will be enrolled in that recent class.
Here is my UPDATE statement:
UPDATE table1 fs SET class = (SELECT a. Table 2 from Table 2 with a WHERE TRIM (a.t2id) ) = TRIM (fs.t1id) and TO_DATE (a.loaddt, 'DD-MON-YY') = TO_DATE ((Select MAX (loaddt) Table 2 ARA, where trim (A TDID) = TRIM (AAATAIDID), ' DD-MON-YY and ROEUUn = 1) and ROEUUEN = 1) TO_DATE (Load DT, 'DD-MN-YY') = TO_DATE (Select MAX (Loadedi) from Table 1), 'DD- MON-Y Y ');
My updates too many lines tap (90%) Even if TABLE2.CLASSNAME does not have any taps.
I have not used in the enrollment update.
Am I missing something? Can you please help?
ROWNUM = 1
almost always Can be translated "Choose a quasi-random line" In many cases (like yours), you are very good using analytical questions, if for any other reason and Less error prone not.
This answer is based on the solution of Multisync @, but I do not like to use sub-questions in the SET
section while updating correlated rows, I MERGE Using
:
like to use in table 1 (selection classname, t2id FROM (select t2id, classname, ROW_NUMBER ()) (Part T2ID ORDER BY Loaddt DESC) RW from table 2) WHERE a.rw = 1) b ON (TRIM (b.t2id) = TRIM (fs.t1id)) when updated SET class = b.classname WHERE TO_DATE (loaddt, ' DD-MON-YY ') = TO_DATE ((t Choose force 1 MAX (Lodditi), "DD-Moan-Y ');
Comments
Post a Comment