On Tue, Mar 3, 2009 at 8:55 AM, Ross <real...@gmail.com> wrote: > > I have started using aggregation, but it seems to ignore any slicing I > do on a QuerySet before calling aggregate. This is what I'm doing: > > Product.objects.order_by("-price")[:100].values("price").aggregate(Max > ("price"), Min("price")) > > I want the maximum and minimum price for the products with the top 100 > largest prices. The aggregate function, however, returns the maximum > and minimum price for all Products--it ignores the [:100] slice. > > Is this an improper use of aggregation, or am I doing something wrong > with my query? > > > Before an aggregation is preformed all limits are removed, so you are seeing expected behavior. I can't remember why this behavior exists though :/
Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---