Hello,
I'm trying to order a list with aggregations. For a restaurant, I have
a visit list and i generate a customer list using
customer_list=visit_list.values('customer_no').annotate(Sum('totalbill')).order_by('totalbill_sum')
(visit class has visit no, customer no and totalbill models)

I want to order the visit_list in line with the aggregate field
totalbill_sum.For example:
visit no           customer no:           totalbill:
V1                     C5                        10
V2                     C5                        12
V3                     C1                        20
V4                     C2                        30
V5                     C2                        10
V6                     C2                        5

This gives customer list as
C2 ,totalbill_sum=45
C5 ,totalbill_sum=22
C1 ,totalbill_sum=20

In need Visit_list to be ordered as
V4
V5
V6
V1
V2
V3

Is there a way to do this?Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to