[Cubicweb] Complex RQL request

Adrien Di Mascio adrien.dimascio at logilab.fr
Thu May 31 09:29:46 CEST 2012


Hi Stéphane,

On 30/05/2012 18:14, Stephane BUGAT wrote:
> In our TERESA CW application, I'm trying to elaborate a RQL request to
> sort the number of resolved incidents during the last month per
> application and per incident type ('blocking', 'major' and so on).
> My request is :

The following rql query might work :

Any A, SUM(F1), SUM(F2) GROUPBY A WITH A,F1,F2 BEING (
(
Any A1,SUM(F1),0 GROUPBY A1 WHERE A1 is Application, A1 has_incident D1,
   D1 gravite "majeur", D1 nb_incidents_meme_nature F1, D1 date_fin DF1
   HAVING (MONTH(DF1)=MONTH(TODAY)-1)
)
UNION
(
Any A2,0,SUM(F2) GROUPBY A2 WHERE A2 is Application, A2 has_incident D2,
   D2 gravite "bloquant", D2 nb_incidents_meme_nature F2, D2 date_fin DF2
   HAVING(MONTH(DF2)=MONTH(TODAY)-1)
))

Besides, note that MONTH(TODAY)-1 won't work for january and would fetch 
objects from past years too.

-- 
Adrien Di Mascio - LOGILAB, Paris (France).
Tél: 01.45.32.03.12
Formations - http://www.logilab.fr/formations
Développements - http://www.logilab.fr/services
Gestion de connaissances - http://www.cubicweb.org/





More information about the Cubicweb mailing list