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.

Sort Order: Ascending order - Click to sort in descending order
Renato Garcia added a comment - 17/Nov/12 01:24 AM
Patch for a test a case

Andy Jefferson added a comment - 12/Feb/13 03:04 PM
SVN trunk passes on this test