SQL在指定的列中显示一列的和

对表中的一列求和,并在该表指定的一列中显示
或者将一列求和到的值修改该表中的一列第一个。
请给出具体的SQL语句

第1个回答  2010-04-10
直接的写法
update test_sum
set col2 = (select sum(col1) from test_sum where col1 is not null)

col1 求和列, col2 目标列, mssql测试通过。
第2个回答  2010-04-10
declare @iSum float
set @iSum = select sum(col1) from tbl1
update tbl1 set col2 = @iSum where col_id = 1本回答被提问者采纳
相似回答