1:
Select IsNull(语文,0) + isNull(数学,0) + IsNull(外语,0) as 总分,
(case when IsNull(语文,0) + isNull(数学,0) + IsNull(外语,0) = 0 then 0 else
(IsNull(语文,0) + isNull(数学,0) + IsNull(外语,0))/
((case when 语文 is null then 0 else 1 end) + (case when 语文 is null then 0 else 1 end)+(case when 语文 is null then 0 else 1 end)) end as 平均值
from 成绩表
Select IsNull(语文,0) + isNull(数学,0) + IsNull(外语,0) as 总分,
(case when IsNull(语文,0) + isNull(数学,0) + IsNull(外语,0) = 0 then 0 else
(IsNull(语文,0) + isNull(数学,0) + IsNull(外语,0))/
((case when 语文 is null then 0 else 1 end) + (case when 语文 is null then 0 else 1 end)+(case when 语文 is null then 0 else 1 end)) end as 平均值
from 成绩表
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货