Opened 13 years ago
Closed 13 years ago
#16775 closed New feature (duplicate)
Support for simple arithmetic in ORM annotations
Description ¶
I would like to use the Django ORM to run a query such as the following:
SELECT SUM(amount * quantity) FROM orders;
Right now, I'm not sure this is possible. As for a potential API, I might suggest something like this:
Order.objects.annotate(sum=Sum(F("amount") * F("quantity")))
Thoughts? Suggestions?
Note:
See TracTickets
for help on using tickets.
Duplicate of #14030.