开发者

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

开发者_JAVA百科
SELECT u,v,x,y,z,count(1) FROM table1 group by  u,v,x,y,z order by  5,6;


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')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜