SQL Server AVG وظيفة غرائب
-
21-09-2019 - |
سؤال
أنا أرى بعض السلوك الغريب في SQL Server AVG calcuation.
على دليل حساب, يمكنك الحصول على 49.277588
ولكن SQL Server التقارير أن متوسط 50.9914
كما هو مبين أدناه.
السؤال: يمكن للشخص شرح الفرق و لماذا يحدث هذا ؟
يمكنك محاولة الخروج من الاستعلام على AdventureWorks2008 قاعدة البيانات مع الاستعلام التالية
select C.ProductCategoryID, P.ProductSubcategoryID,
AVG(P.ListPrice) as 'Average',
MIN(P.ListPrice) as 'Miniumum',
MAX(P.ListPrice) as 'Maximum'
from Production.Product P
join Production.ProductSubcategory S
on S.ProductSubcategoryID = P.ProductSubcategoryID
join Production.ProductCategory C
on C.ProductCategoryID = S.ProductCategoryID
where P.ListPrice <> 0
group by C.ProductCategoryID, P.ProductSubcategoryID
with rollup
[تحديث] الجواب
هنا هو نتيجة المتوسط المرجح حسابية في Excel
المحلول
يبدو أنك تفعل متوسط متوسط في Excel ، التي هي سيئة في الرياضيات.
http://wiki.answers.com/Q/Is_an_average_of_averages_accurate
لا تنتمي إلى StackOverflow