How to use aggregation/group by in subquery #3045
Replies: 1 comment 1 reply
-
|
There is https://groups.google.com/g/ebean/c/30NW-wmP5k0 which asks a similar question. Generally it seems there is no way to explicitly ask for a group by clause unless you use raw sql in one way or another. Obviously raw sql strings are always bad in terms of refactors. Given that Ebean already has a The following examples use Ebean QueryBeans but to some extend also apply to Given your example something like requires the reader to know that that If Ebean would provide a if desired which makes query understanding easier for people not super familiar with Ebean and more importantly you could do to solve your issue in a type safe manner. With newest Ebean and if you are fine using experimental API you could also make the aggregate more visible by using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone, Hi @rob-bygrave,
We are currently trying to use an Aggregation query as
insubquery. We write the subquery as the following :[PseudoCode]
Note : lastKnownAd is an @Aggregation column allowing to get the most recent ad_id for a given product.
We use "product" in first place of the
selectin order for Ebean to generate the correctGROUP BYclause.However, we do not want the "product" to be in the select clase because a subquery should have only one column to be usable with
incondition. Is there a way to tip Ebean about the group by column to use without adding it to the select clause ?Thanks in advance for your help.
Yours faithfully,
LCDP
Beta Was this translation helpful? Give feedback.
All reactions