user3836657
user3836657

Reputation: 1

group by multiple fileds and order by count of group in python/django

Please help me in getting the result of below in django/python

SELECT u,v,x,y,z,count(1) FROM table1 group by  u,v,x,y,z order by  5,6;

Upvotes: 0

Views: 532

Answers (1)

Botond Béres
Botond Béres

Reputation: 16673

Not sure what you mean by order by 5,6, I assume you have columns with that name...

Anyway, it should work like this:

results = MyModelForTable1.objects.values('u', 'v', 'x', 'y', 'z').annotate(Count('u')).order_by('5', '6')

Upvotes: 1

Related Questions