Dear Django users.
I'm trying to do the sums of the product of two columns ('contract_sum' and
'probability', decimal fields), grouping by a third column, 'stage' (a
choice variable).
I'm also reporting the grouped sums of one of the single columns
('contract_sum')
The single column works just fine, but I just can't get it right with the
product columns.
Below is my code so far:
contracts = (Project.objects.values('stage')
.annotate(contract_sum=Sum('contractSum'))
.annotate(expected_own_production_sum=F(
'contractSum')*F('probability'))
)
a) When I run the query with the single column query, the results are right.
b) When I run the query with both selections, not only is the column
product, wrong, but the single column sums also become wrong.
c) When I run the query with only the product columns, the query returns
zero for all groups, which is definitely wrong.
Can I do this right without going to raw sql?
cheers + thanks, Mikkel
--
You received this message because you are subscribed to the Google Groups
"Django users" 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].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/4a6af6b6-d76e-43f7-8223-23da3ead38da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.