现在我弄了一张测试表,里面有下面四行数据,我想对这些数据求方差,用select var(num) from tb,结果算出的结果为1.3333333333,可是我按照方差公式σ^2=1/n ∑_(i=0)^n▒(x_i-¯x)^2  ,得出的应该是1啊,这是什么原因?难道var()函数不可靠?盼熟悉的人给指点下。
num
5
3
3
5

解决方案 »

  1.   

    你用公式的时候是不是全部用的INT型??你可以在后面加个.0
      

  2.   

    楼主可以试试select 1.0/3
    select 1/3
    的结果 
      

  3.   

    --建表
    create table #test(a int)insert into #test
    select 5 union all select 3 union all select 3 union all select 5select varp(a) from #test--结果----------------------
    1(1 行受影响)
      

  4.   

    原来是使用varp,我用错函数了。