Task is to sum 'ukupna bilansna i vanbilansna aktiva' for the same 'ID_Grupe' after the relation between TABLE_A and TABLE_B on 'mbr' and 'GRP_ID' has been made.
(mbr and GRP_ID are clients id card numbers)
Afterwards, we need to update summed values in TABLE_C in the column 'IDV_REL_P_ESR_AMT' after joining on the same 'ID_IDENTN_NUM'.
So you can think of ID_IDENTN_NUM,mbr and GRP_ID as same id card number.
How can I do joins between three tables, along with an UPDATE and SET statements?
This is my idea:
UPDATE B2_INPT_CR_IP_SNPST AS c
SET IDV_REL_P_ESR_AMT = (SELECT ID_Grupe, SUM(ukupna_bilansna_i_vanbilansna_aktiva)
FROM rm_tb_portfolio AS a
INNER JOIN B2_INPT_CR_GRP_SNPST AS b ON a.mbr = b.GRP_ID
GROUP BY ID_Grupe)
WHERE c.IP_IDENTN_NUM = a.mbr