数据表结构如下:
A B C D E
------------------------------------------------------------
123 25 11 11 null
123 85 21 21 null
456 25 8 8 null我想将C、D相加并写入E,这样的SQL语句怎么写?
A B C D E
------------------------------------------------------------
123 25 11 11 null
123 85 21 21 null
456 25 8 8 null我想将C、D相加并写入E,这样的SQL语句怎么写?
例:create table table67(c int,d int,e as c+d)
FROM table2 INNER JOIN
table1 ON table2.Barcode = table1.Barcode
where table2.w = '123'
select table.*,convert(decimal(20,6),c+d) e
FROM table2 INNER JOIN
table1 ON table2.Barcode = table1.Barcode
where table2.w = '123'
SELECT table1.*
FROM table2 INNER JOIN
table1 ON table2.Barcode = table1.Barcode
where table2.w = '123'然后操作查询出来的记录,将table1.C + table1.D写入table1.E
----------------
首先要保证你的c d e字段类型是可有小数的 例如float numeric decimal