﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19011	Annotating multiple Sum() objects gives wrong answer	tBuLi	nobody	"This is best explained with an example:

{{{
queryset = Member.objects.annotate(payed=Sum('payment__amount'))
queryset = Member.objects.annotate(discount=Sum('membership__discount__amount'))
}}}

These give the right payed and discount amount for the member, whereas

{{{
queryset = Member.objects.annotate(discount=Sum('membership__discount__amount'), payed=Sum('payment__amount'))
}}}

gives a value for payed which is a factor 2 higher, and the discount is a factor 3 higher. Using exactly the same syntax with Count() gives the correct answer in both cases, so I suspect something goes wrong with Sum().

using distinct = True does not matter."	Bug	closed	Database layer (models, ORM)	1.4	Normal	duplicate	annotate, sum		Unreviewed	0	0	0	0	0	0
