sqlserver 同时更新一张表的多个列
?UPDATE tablename1?
?SET?? tablename1 .JLDQCYE = tablename2.QC? ,
?????????? tablename1.JLDBQZJ = tablename2.ZJ ,
?????????? tablename1.JLDQMYE= tablename2.QM???????
?FROM
???? (
???????? SELECT * FROM (
???SELECT B.JLDNM , SUM(B.QC) QC ,SUM(B.ZJ ) ZJ ,SUM(B.QM) QM?? FROM
????????? (
??????? SELECT C.JLDNM , 0 QC? , 0 ZJ , C.JLDJE QM? FROM VW_ZJGXJLD_JBXX? C WHERE? C.jldqrrq <= '20130930'
????????? ) B GROUP BY B.JLDNM
???????? )? biename1
????? ) tablename2 ,tablename1???????????????????
WHERE tablename2.JLDNM = tablename1.JLDNM?
?
注意点:biename1必须要加(查询出来的结果集要加别名)tablename2 也要加
?