#25977: Allow different filters on multiple aggrigates
-------------------------------+----------------------------
     Reporter:  agronick       |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Uncategorized  |    Version:  1.9
     Severity:  Normal         |   Keywords:  QuerySet.extra
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+----------------------------
 This is the query I that appears to be impossible to implement using the
 ORM:

 SELECT id, name, start_date,
 (SELECT count(state) FROM jobs_job WHERE  state = 'F' and job_group_id  =
 jg.id GROUP BY state) as badcount ,
 (SELECT count(state) FROM jobs_job WHERE state = 'C'  and job_group_id  =
 jg.id GROUP BY state) as goodcount
 FROM jobs_jobgroup as jg

 The main table represents a job group. The two queries tell how many
 successes and failures there are in the jobs for the job group. Currently,
 there is no way to have multiple aggregates with different filters on each
 one. You can't do
 annotate(fail_count=Count('job__state').filter(state='F'),
 good_count=Count('job__state').filter(state='C')) or something similar.

--
Ticket URL: <https://code.djangoproject.com/ticket/25977>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.f2566a70f64ad9b5e280fed64297f249%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to