The same rules apply to the aggregate() clause. If you wanted to know the lowest and highest price of any book that is available for sale in a store, you could use the aggregate:
Store.objects.annotate(min_price=Min('books__price'), max_price=Max('books__price'))
Store.objects.aggregate(min_price=Min('books__price'), max_price=Max('books__price'))
Can you perhaps order by price and get first and last items?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/814ef5a3-6e2b-4054-9a1c-6ca127c2d527%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Publisher-a | |||
Publisher-b | |||
Book | |||
id | |||
2 | book_1 | 1$ | Publisher-a |
7 | book_2 | 2$ | Publisher-b |
9 | book_3 | 0,5$ | Publisher-a |
14 | book_2 | 4$ | Publisher-b |