Created
November 22, 2012 09:29
-
-
Save vkgtaro/4130198 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from apps.appname.models import Receivable | |
| from django.db.models import Sum | |
| receivable = Receivable.objects.all() | |
| receivable.query.group_by = ['client_id'] | |
| receivable.annotate( total_price = Sum('price') ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT client_id, sum(price_total) as total FROM appname_receivable group by client_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment