سؤال

أنا أرى بعض السلوك الغريب في 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

alt text

[تحديث] الجواب
هنا هو نتيجة المتوسط المرجح حسابية في Excel alt text

هل كانت مفيدة؟

المحلول

يبدو أنك تفعل متوسط متوسط في Excel ، التي هي سيئة في الرياضيات.

http://wiki.answers.com/Q/Is_an_average_of_averages_accurate

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top