#11088: Aggregation problem, table JOINed twice
--------------------------------------+-------------------------------------
Reporter: [email protected] | Owner:
Status: new | Milestone: 1.1
Component: ORM aggregation | Version: 1.1-beta-1
Resolution: | Keywords: aggregation, join
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------+-------------------------------------
Changes (by mir):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Your query means to first annotate, counting the visitorlog entries for
all actions, and then afterwards apply the filter to the annotated query.
I think you have to swap the annotate and filter clauses in your query to
get what you intend:
{{{
Video.objects.filter(visitorlog__action__name = 'play').annotate(play_log
= Count('visitorlog')).order_by('-play_log')[0:10]
}}}
I'm not particularily experienced with annotations, so I don't want to
close your ticket without your confirmation that you see it the same way.
--
Ticket URL: <http://code.djangoproject.com/ticket/11088#comment:1>
Django <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---