我基本上喜欢和这个问题一样,但是通过两个值的组合进行分组,而不仅仅是一个:
SELECT player_type, team, COUNT(*) FROM players GROUP BY player_type, team;
Run Code Online (Sandbox Code Playgroud)
有没有人知道在Django中这是否可行以及如何实现?我正在使用1.2.
Ama*_*osh 23
Player.objects.values('player_type', 'team').order_by().annotate(Count('player_type'), Count('team'))
Run Code Online (Sandbox Code Playgroud)