Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Adding a field in Group by gives different result.

Author  Topic 

eurob
Posting Yak Master

100 Posts

Posted - 2006-01-09 : 13:38:54
Before grouping this select statement gives a result:10.05 (single rows added up)


SELECT count(A.auditid) * CAST(sum(totalerrors) as decimal(9,2)) / SUM(totalitems) as [errors]
from Audits A
WHERE A.CycleID = 36 AND A.formid = 1002


After I group it on A.Clientid it gives me: 12.33.

I really wonder why this is happening...

Any ideas ?

robert

eurob
Posting Yak Master

100 Posts

Posted - 2006-01-09 : 14:29:11
I know that it is something in the rounding, 12.33 would be correct with these values:


0.324324324
0.27027027
0.135135135
0.68
2.948816731
1.972972973
1.027027027
0.243243243
0.918918919
1.405405405
0.648648649
0.810810811
0.945945946
-----------
12.33151943


robert
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-01-09 : 15:08:29
You are going to need to provide us the CREATE TABLE statement for the table, INSERT INTO statements for sample data (for us to play with), and the expected result set using that sample data.

Tara Kizer
aka tduggan
Go to Top of Page
   

- Advertisement -