Bug #64010 Incorrect SUM values of Decimal data type from View results
Submitted: 12 Jan 2012 14:01 Modified: 12 Feb 2012 17:43
Reporter: Van Stokes Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.5.19 x64 OS:Linux (Ubuntu 11.10 x86_64)
Assigned to: CPU Architecture:Any
Tags: avg, GROUP BY, sum, VIEW

[12 Jan 2012 14:01] Van Stokes
Description:
The SUM() and AVG() values are incorrect when using a SUM() or AVG() aggregate function using the data results from a VIEW .

The VIEW is also performing a SUM() of columns. The VIEW does produce the correct SUM() results directly from the table.

This appears with the DECIMAL data type. The INTEGER data type works fine.

How to repeat:
Create a VIEW to SUM() a decimal data type. Then attempt to SUM() the results of the decimal column from the view:

Works from table called from a View:
SELECT SUM( Int Type) AS 'ViewIntType', SUM(Decimal Type) AS 'ViewDecimalType' from TABLE;

Does NOT work when summing the results from a VIEW:
SELECT SUM(ViewIntType), SUM(ViewDecimalType) from VIEW;

ViewIntType will be correct.
ViewDecimalType will be incorrect.

Suggested fix:
Not sure.
[12 Jan 2012 14:02] Van Stokes
I believe this to be a serious issue.
[12 Jan 2012 16:08] Sveta Smirnova
Thank you for the report.

Please send us wrong results you get and what do you expect from the query to return.
[12 Jan 2012 17:32] Van Stokes
I have re-uploaded a file to you. It has two new sheets: Wrong and Expected.
[12 Jan 2012 17:43] Sveta Smirnova
Thank you for the feedback.

In the file with invalid SQL you ask for 5 fields while in results you send much more. Results look more like if you did SELECT * FROM view, but you wrote such a query returns correct results. Please either provide real query you used to get these results or results for "invalid query".
[13 Feb 2012 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".