Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

update column based on sum of data from another table

user13594370Dec 2 2014 — edited Dec 2 2014

I have two tables :

Table1 (col1, col2, col3, col4, val1, status) Table2 (col1, col2, col3, col4, val2)

For Table1 and Table2, The column (col1, col2, col3, col4) are the composit primary key.

Table2 may have duplicated rows, for that reason i would like to group by (col1, col2, col3, col4) and sum(val2)

After that, i would like to update Table1.val1 by the value of sum(Table1.val2) when Table1.col1 = Table2.col1 and Table1.col2 = Table2.col2 and Table1.col3 = Table2.col3 and Table1.col4 = Table2.col4 and status= 'V'.

I did something like that:

UPDATE Table1 SET val1 = (

   

WHERE Table1.col1 = t_sommevbrute.col1 and Table1.col2 = t_sommevbrute.col2 and Table1.col3 = t_sommevbrute.col3 and Table1.col4 = t_sommevbrute.col4)

Could someone help me please? Thank you

This post has been answered by Karthick2003 on Dec 2 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 30 2014
Added on Dec 2 2014
3 comments
2,092 views