[Dbix-class] Selecting max() of count()

BUNK (Jacob Bunk Nielsen) bunk at novozymes.com
Fri Aug 1 10:54:36 BST 2008


luke saunders <luke.saunders at gmail.com> writes:
> BUNK (Jacob Bunk Nielsen) <bunk at novozymes.com> wrote:
> [ ... ]
>> I'm trying to write the equivalent of:
>>
>> select
>> max(no_of_items) from
>> (select count(item_id) as no_of_items
>>  from shop.basket where basket_id=1 or basket_id=2
>>  group by basket_id) foo;
>>
>> [ ... ]
>
> Could be a ResultSetColumn bug. What's the SQL you are actually expecting?

Something like the above.

It has to be done with a sub select because you can't nest aggregate
functions like max() and count().

Best regards

Jacob



More information about the DBIx-Class mailing list