17,740
社区成员
发帖
与我相关
我的任务
分享
select id, (core_1+core_2+core_3),
(case when core_1=0 then 0 else 1 end)+
(case when core_2=0 then 0 else 1 end)+
(case when core_3=0 then 0 else 1 end)
from [表名]
select id, (core_1+core_2+core_3) as [sum],
case when core_1+core_2+core_3=0 then 0 else (core_1+core_2+core_3)/(sign(core_1)+sign(core_2)+sign(core_3)) end as [average]
from [表名]
select id,isnull(core_1,0)+isnull(core_2,0)+isnull(core_3,0) as 总分
,(isnull(core_1,0)+isnull(core_2,0)+isnull(core_3,0))/(case when core_1 is null then 0 else 1 end +case when core_2 is null then 0 else 1 end +case when core_3 is null then 0 else 1 end) as 平均分
from [表名];