I am using SQL Server 2008, one of my requirements is to calculate population standard deviation. SQL Server provides a built-in function stdevp
for the same. I am using it but I am befuddled by the result I am getting. Population standard deviation for a group of same numbers should be zero but here I get some different although minuscule value.
drop table guest.tempTable;
create table guest.tempTable (column1 varchar , column2 decimal(10,6))
insert into guest.tempTable values('a',3578.2700);
insert into guest.tempTable values('a',3578.2700);
insert into guest.tempTable values('a',3578.2700);
insert into guest.tempTable values('a',3578.2700);
insert into guest.tempTable values('a',3578.2700);
commit;
The following is the stdevp query:
select stdevp(column2) from guest.tempTable
group by column1
The result that I get is
------------------------
5.459150335692846E-5
which should have been 0.00.
The documentation for stdevp
says that it returns a float. So I am guessing this must be a rounding off issue, but I am unable to find a solution.