Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] SUM in HAVING clause

Hi Jakob,

The exception you are seeing is indicating that you can only use HAVING with things that are described in the GROUP BY section of the query.

i.e. To use SUM(p.betrag) in the having clause, either SUM(p.betrag) or p.betrag must appear in the GROUP BY clause.

-Tom

Jakob Braeuchi wrote:
hi,

i just downloaded the new eclipselinks 1.0. afaik it's based on oracle toplink and it still has problems with SUM in the HAVING clause.

the following query:

select new ch.brj.ekv.type.KaufShort(k.id, k.datum, k.einkaufer.name, SUM(p.betrag))
from Kauf k, in(k.posten) p
where k.datum between :datVon and :datBis
group by k.id, k.datum, k.einkaufer.name
having SUM(p.betrag) between :betrVon and :betrBis
order by k.datum asc

results in an error with this message:

"The HAVING clause must specify search conditions over the grouping items or aggregate functions that apply to grouping items."

the only item i use in the having-clause is the aggregate SUM(p.betrag).
could you please tell me what's wrong here ? does it violate the JPQL spec ?

btw this query works with hibernate.

jakob

ps: i have posted the same question in the oracle toplink forums in 2006 and 2007 (google for toplink having sum)
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top