着急啊!关于一道数学题!!谢谢啦!!!真的谢谢啦!!!!!在线等!!
数据库中有一个字段该字段下是任意的分数(10,20,30....),求用每个分数减去该列的平均数,然后取其绝对值,再然后对绝对值求和,用这个和除以各个分数的个数;
该怎么实现啊???谢谢啦!!!
------解决方案--------------------这样?
declare @t table(score int)
insert @t
select 10 union all
select 20 union all
select 30
SELECT 1.00*sum(abs_score)/(select count(score) from @t) as result FROM
(select abs(score - (select avg(score) from @t)) as abs_score from @t) as a
/*结果
result
------------------
6.66
*/