DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCRDBMS-623
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Renato Garcia
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

Wrong result when using aggregate in HAVING clause

Created: 17/Nov/12 01:21 AM   Updated: 12/Feb/13 05:14 PM   Resolved: 12/Feb/13 03:04 PM
Component/s: Queries
Affects Version/s: 3.1.3
Fix Version/s: 3.2.0.m4

File Attachments: 1. File test-patch-NUCRDBMS-623 (3 kB)


Forum Thread URL: http://www.datanucleus.org/servlet/forum/viewthread_thread,7101
Datastore: MySQL
Severity: Development


 Description  « Hide
A query like this:
SELECT department, avg(salary) FROM Employee GROUP BY department HAVING avg(salary) > 6

evaluates to this SQL:
SELECT `A0`.`DEPARTMENT`,AVG(`A0`.`SALARY`) FROM `EMPLOYEE` `A0` GROUP BY `A0`.`DEPARTMENT` HAVING ((SELECT AVG(`A0`.`SALARY`) FROM `EMPLOYEE` `A0`) > 6)

when it should evaluate to something like:
SELECT `A0`.`DEPARTMENT`,AVG(`A0`.`SALARY`) FROM `EMPLOYEE` `A0` GROUP BY `A0`.`DEPARTMENT` HAVING AVG(`A0`.`SALARY`) > 6;

Please see the thread for more details.

Renato Garcia added a comment - 17/Nov/12 01:24 AM
Patch for a test a case

Renato Garcia made changes - 17/Nov/12 01:24 AM
Field Original Value New Value
Attachment test-patch-NUCRDBMS-623 [ 11801 ]
Andy Jefferson added a comment - 12/Feb/13 03:04 PM
SVN trunk passes on this test

Andy Jefferson made changes - 12/Feb/13 03:04 PM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.2.0.m4 [ 11883 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 12/Feb/13 04:55 PM
Summary Wrong result when using having in a JDOQL query Wrong result when using aggregate in HAVING clause
Andy Jefferson made changes - 12/Feb/13 05:14 PM
Status Resolved [ 5 ] Closed [ 6 ]