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!

Merge vs Update with multiple tables and columns

chillychinSep 6 2013 — edited Sep 10 2013

I am trying to update multiple columns from one table based on the results of another table

So I have 3 tables as follows

HISTORY

SUMM_SNAP

ADM_CHOICE

My SQL code is loosely

SELECT SUM(H.HIS1), SS.SNAP1, AC.ADM1

FROM

HISTORY H,

SUMM_SNAP SS,

ADM_CHOICE AC

WHERE H.HIS2=SS.SNAP2

AND SS.SNAP3=AC.ADM2

GROUP BY SS.SNAP1, AC.ADM1

This works, and I am able to SUM the column as I need with the right numbers.

I altered the SUMM_SNAP table and now I want this summarized column to be in the table

I tried using UPDATE, but there is no FROM clause to let me do the table join/group by

UPDATE SUMM_SNAP

SET SUMM_SNAP.SNAP3=SUM(H.HIS1)

FROM

HISTORY H,

SUMM_SNAP SS,

ADM_CHOICE AC

WHERE H.HIS2=SS.SNAP2

AND SS.SNAP3=AC.ADM2

GROUP BY SS.SNAP1, AC.ADM1

The above is obviously wrong - but just trying to show whatI was thinking

What would be the best method to get the numbers from the SUM into a table?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 8 2013
Added on Sep 6 2013
5 comments
1,145 views