Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db.models import Max, Sum
- queryset = queryset.values('period', 'cell').annotate(x=Max('total'))
- result = queryset.values(period).annotate(result=Sum('x'))
- period cell total
- 1 2 40
- 1 2 41
- 2 3 23
- 1 4 44
- queryset = queryset.values('period', 'cell').annotate(x=Max('total'))
- period cell x
- 1 2 41
- 2 3 23
- 1 4 44
- period result
- 1 85
- 2 23
Add Comment
Please, Sign In to add comment