0

以下のクエリを使用して列を更新していますが、更新できません。

update table1
 set month_0val = (select v1.sumvalue 
 from ( select r1.reg_id, sum(backbook.bal) as sumvalue
 from  table2 backbook , table3 s , table4 r1
 where month(backbook.Date_AsOf) = month(s.MONTH_AS_OF - INTERVAL 12 MONTH) and year(backbook.Date_AsOf) =  year(s.MONTH_AS_OF - INTERVAL 12 MONTH)  and  backbook.a_region_id = r1.region_code
 and r1.org_id = org_id and  backbook.A_ProdType_Code != 25  and s.SC_ID = sc_id group by backbook.A_Region_ID ) v1
 where v1.reg_id = table1.Region);

内部クエリでも結果が返されます。

助けてください。

4

1 に答える 1

0
UPDATE table1, ( 
            select r1.reg_id, sum(backbook.bal) as sumvalue
            from  table2 backbook , table3 s , table4 r1
            where month(backbook.Date_AsOf) = month(s.MONTH_AS_OF - INTERVAL 12 MONTH) 
              and year(backbook.Date_AsOf) =  year(s.MONTH_AS_OF - INTERVAL 12 MONTH)  
              and  backbook.a_region_id = r1.region_code
              and r1.org_id = org_id 
              and  backbook.A_ProdType_Code != 25  
              and s.SC_ID = sc_id 
            group by backbook.A_Region_ID 
            ) v1
SET table1.month_0val = v1.sumvalue
WHERE v1.reg_id = table1.Region;
于 2012-07-26T07:37:31.620 に答える