You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Andrey Razumovsky <ra...@gmail.com> on 2010/01/28 11:47:27 UTC
EJBQL: clause for count() statement?
Hi,
Imagine I need to select all artists with their painting count. That's how I
do that
select a, count(p) from Artist a inner join a.paintings p group by a
I need to select all artists that have >5 paintings... how can I do that? I
thought I need something like aliases, but our EJBQL doesn't support it:
select a, count(p) AS pCount from Artist a inner join a.paintings p where
pCount>5 group by a
Is there any way to do that?
--
Andrey
Re: EJBQL: clause for count() statement?
Posted by Andrey Razumovsky <ra...@gmail.com>.
thanks, but how then can i order the list by paintings count?
2010/1/28 Andrus Adamchik <an...@objectstyle.org>
> This should work:
>
> select a, count(p) from Artist a join a.paintings p group by a having
> count(p) > 5
>
> Andrus
>
>
>
> On Jan 28, 2010, at 12:47 PM, Andrey Razumovsky wrote:
>
> Hi,
>>
>> Imagine I need to select all artists with their painting count. That's how
>> I
>> do that
>> select a, count(p) from Artist a inner join a.paintings p group by a
>>
>> I need to select all artists that have >5 paintings... how can I do that?
>> I
>> thought I need something like aliases, but our EJBQL doesn't support it:
>> select a, count(p) AS pCount from Artist a inner join a.paintings p where
>> pCount>5 group by a
>>
>> Is there any way to do that?
>> --
>> Andrey
>>
>
>
--
Andrey
Re: EJBQL: clause for count() statement?
Posted by Andrus Adamchik <an...@objectstyle.org>.
This should work:
select a, count(p) from Artist a join a.paintings p group by a
having count(p) > 5
Andrus
On Jan 28, 2010, at 12:47 PM, Andrey Razumovsky wrote:
> Hi,
>
> Imagine I need to select all artists with their painting count.
> That's how I
> do that
> select a, count(p) from Artist a inner join a.paintings p group by a
>
> I need to select all artists that have >5 paintings... how can I do
> that? I
> thought I need something like aliases, but our EJBQL doesn't support
> it:
> select a, count(p) AS pCount from Artist a inner join a.paintings p
> where
> pCount>5 group by a
>
> Is there any way to do that?
> --
> Andrey