#11305: Support for "Conditional Aggregates"
-------------------------------------+-------------------------------------
Reporter: bendavis78 | Owner:
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: aggregate, annotate | Someday/Maybe
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by shaib):
It should be noted that the use-case in the ticket description might be
better served by allowing better grouping options. That is, the ideal SQL
is not
{{{
SELECT
item,
COUNT(IF(ethnicity='caucasian',TRUE,NULL)) AS caucasian_count,
COUNT(IF(ethnicity='african_american',TRUE,NULL)) AS
african_american_count
...
}}}
but rather
{{{
SELECT
item, ethnicity, COUNT(*)
FROM orders
JOIN items ON ...
JOIN users ON ...
GROUP BY item, ethnicity
}}}
Such grouping is currently not supported by the Django ORM, and I am not
aware of a proposal to add it.
--
Ticket URL: <https://code.djangoproject.com/ticket/11305#comment:37>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.c05597597300b04caca55c87de5e86e9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.