[Cubicweb] RQL Question

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Sep 26 09:01:27 CEST 2011


On 25 septembre 19:01, Adrien Di Mascio wrote:
> 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

yup, you can't achieve this without subqueries, as you couldn't in SQL.
-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org




More information about the Cubicweb mailing list