我仍然遇到同样的问题。希望您能在解决方案中合作。我想在Django中获取此查询的结果。
SELECT city_name, MAX(total_places) total_places
FROM(SELECT city city_name, COUNT(city) total_places
FROM Places
GROUP BY 1) t1
GROUP BY 1;
答案 0 :(得分:0)
如果我看着this answer,应该是这样的:
Places.objects.annotate(total=COUNT('city')).latest('total')