Theofanis Despoudis
Gamer.objects.all().aggregate(unique=Count('id'))
Gamer.objects.all().exclude(won=False).aggregate(num_wins=Count('won'))
# avg points per gave
GameSessionResult.objects.all().aggregate(Avg('score'),StdDev('score'),Variance('score'))
summary per row/object
scores = GameSessionResult.objects.all().annotate(Sum('gamersessionresult__score'))
scores[0].gamesessionresult__score__sum
scores = GameSessionResult.objects.all().annotate(
sum_scores=Sum('gamesessionresult__score')),
...)
Gamer.objects.all().annotate(sum_points=Sum('gamesessionresult__score'))\
.filter(not null).order_by('sum_points')[:5]
# group by
GameServer.objects.values('region').annotate(num_users=Count('gamers'))