想要增加一列成绩总和。怎么使用SQL语句实现呢。
用union联合一个select sum
select 表 名.*,(math+englisth+chinese) as 总和 from 表 名
select [现有列名],三科成绩总和=(math+english+chinese) from table
优化:select [现有列名],三科成绩总和=(isnull(math,0) +isnull(english,0)+isnull(chinses,0)) from table
不要把统计和硬写在数据库中,应该用
select *, (math+englisth+chinese) as 统计和 from table
select t.*, (math+englisth+chinese) as sum from table t
select *, (math+englisth+chinese) as sum from table t