Question

I'm trying to write a query that returns all departments whose average salary of employees is within the specified range.

I have something like this:

Query query = pm.newQuery(Employee.class);
query.setResult("department, avg(salary)");
query.setGrouping("department HAVING avg(salary) >= :x && avg(salary) <= :y");
query.setOrdering("2 desc");

Problem is, that avg(salary) is counted again in HAVING, so I get all departments if avg(salary) is in the range or I get empty list of results otherwise. Any ideas?

Was it helpful?

Solution

Actually it's fixed since version 3.2.0-m4 Look here: http://www.datanucleus.org/servlet/jira/browse/NUCRDBMS-623

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top