[Cubicweb] RQL Question

Adrien Di Mascio adimasci at gmail.com
Sun Sep 25 19:01:08 CEST 2011


Hi Alexandre,

On Sun, Sep 25, 2011 at 6:44 PM, Alexandre Fayolle
<alexandre.fayolle at logilab.fr> wrote:
> Any C, Count(A), Count(B) WHERE A is ContentA, A? in_container C, B is
> ContentB, B? in_container C
>
> gives me obviously wrong results (some counts are higher than the total number
> of A and B in the db). Is there a way of computing this in a single query?

You probably need subqueries to achieve this. I would try something like :

Any C, COUNTA, COUNTB WHERE C identity CC
WITH C, COUNTA BEING (Any X, COUNT(A) GROUPBY X WHERE A in_container C),
     CC, COUNTB BEING (Any X, COUNT(B) GROUPBY X WHERE B in_container C)

as stated in the documentation :
http://docs.cubicweb.org/annexes/rql/language.html#sub-queries

Regards,
Adrien.



More information about the Cubicweb mailing list