Bug #65970 | AVG group function when dealing with maximum number give wrong results | ||
---|---|---|---|
Submitted: | 20 Jul 2012 21:50 | Modified: | 21 Jul 2012 17:41 |
Reporter: | calle kula | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 5.5.19, 5.5.26 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | avg, Maximum value |
[20 Jul 2012 21:50]
calle kula
[21 Jul 2012 6:42]
Valeriy Kravchuk
Please, send the exact CREATE TABLE statement used to create the table. Or, even better, just attach the dump of this table.
[21 Jul 2012 16:30]
calle kula
Fair enough =) CREATE TABLE `fundamenta`.`myTestTable` ( `companyID` int(11) DEFAULT NULL, `date` date DEFAULT NULL, `myDouble` double DEFAULT NULL); INSERT INTO myTestTable values (1, '2010-10-01', 1.7976931348623157e308); INSERT INTO myTestTable values (1, '2010-10-02', 1.7976931348623157e308); INSERT INTO myTestTable values (1, '2010-10-03', 1.7976931348623157e308); INSERT INTO myTestTable values (1, '2010-10-04', 1.7976931348623157e308); INSERT INTO myTestTable values (1, '2010-10-05', 1.7976931348623157e308); INSERT INTO myTestTable values (1, '2010-10-06', 1.7976931348623157e308); INSERT INTO myTestTable values (1, '2010-10-07', 1.7976931348623157e308); SELECT MAX(date), AVG(myDouble) FROM myTestTable WHERE companyID = 1 GROUP BY YEARWEEK(date) ORDER BY date DESC; hope this will help you reproduce the error
[21 Jul 2012 17:41]
Valeriy Kravchuk
Thank you for the complete test case. Problem is easy visible with your table, data: mysql> SELECT myDouble FROM myTestTable; +------------------------+ | myDouble | +------------------------+ | 1.7976931348623157e308 | | 1.7976931348623157e308 | | 1.7976931348623157e308 | | 1.7976931348623157e308 | | 1.7976931348623157e308 | | 1.7976931348623157e308 | | 1.7976931348623157e308 | +------------------------+ 7 rows in set (0.00 sec) and even more simple query: mysql> SELECT AVG(myDouble) FROM myTestTable; +---------------+ | AVG(myDouble) | +---------------+ | 0 | +---------------+ 1 row in set (0.00 sec) Verified with 5.5.26 on Mac OS X also.