#30394: Mutiple annotation with Sum return wrong values.
-------------------------------------+-------------------------------------
     Reporter:  Gouri Javed          |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.11
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Gouri Javed):

 * version:  2.2 => 1.11


Old description:

> UserRoleAccount.objects.filter(pk='24f4a032-3f83-4123-8330-fa60fcbb880c').aggregate(
>      given_count=Sum(
>         Case(When(user_observations_given__group=grp, then=1),
>               output_field=IntegerField())
>      ),
>      taken_count=Sum(
>          Case(When(user_observations_taken__group=grp, then=1),
>               output_field=IntegerField())
>      )
>  )

New description:

 
UserRoleAccount.objects.annotate(count=Sum(Case(When(user_observations_taken__group=grp,then=1)),default=0,output_field=IntegerField(),distinct=True)).annotate(count1=Sum(Case(When(user_observations_given__group=grp,then=1)),default=0,output_field=IntegerField(),distinct=True))

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30394#comment:1>
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/068.2ef8a1f888a3e4f3c98ebe6ff09276d0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to