#30592: Selection from subquery
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
EugeneKovalev |
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Right now it is totally impossible to select columns from a subquery.
This is a very simple SQL which Django ORM does not support:
{{{
SELECT name, sum(age) as age FROM (
SELECT name, date, max(age) as age FROM table GROUP BY name, date
) GROUP BY name
}}}
Probably, it can look something like this:
{{{
subq = Table.objects.values('name', 'date').annotate(age=Max('age'))
result = subq.objects.values('name').annotate(age=Sum('age'))
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30592>
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/056.472a653eb822c44ad86c741e285f7b3a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.