Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STDEV domain error

Status
Not open for further replies.

filmr

Programmer
Jan 30, 2002
6
0
0
US
I'm getting a domain error when using the STDEV function.
Seems to be keyed to specific numbers.
Here is an example of the data being used:

Create Table Test(
Code varchar(10),
Amt money )
go

set nocount on
declare @x int
set @x = 1
while @x < 10
begin
Insert into Test values ('abcd',15.46)
set @x = @x + 1
end
go

SELECT Code,
stdev(Amt) as Deviation
FROM Test
group by Code
 
Hi,

I think u r getting the error bcos the data in the sample has no variation, i.e the Standard deviation is zero so change the code like this and see.

Create Table Test(
Code varchar(10),
Amt money )
go

set nocount on
declare @x int
set @x = 1
while @x < 10
begin
Insert into Test values ('abcd',@x)
set @x = @x + 1
end
go

SELECT Code,
stdev(Amt) as Deviation
FROM Test
group by Code


Hope it helps

Sunil
 
This did work. But even if I pick a different value than the 15.46, say 15.25, and populate every record with this value, I don't get the error. Seems like something directly related to the 15.46 value. Seems very strange.

Create Table Test3(
Code varchar(10),
Amt money )
go

set nocount on
declare @x int
set @x = 1
while @x < 10
begin
Insert into Test3 values ('abcd',15.25)
set @x = @x + 1
end
go

SELECT Code,
stdev(Amt) as Deviation
FROM Test3
group by Code
 
Hi,

That is rather strange.... it doesnt like values from 15.43 to 15.48 ...... looks like a bug...

Sunil
 
Appears to be a bug in SQL 7.0.
I found a server with SQL 2000 loaded.
No problems running the query there.

Thanks for the help.
--Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top