Monday, January 28, 2019

Using Django Window Functions on a Filtered QuerySet

I have a filtered queryset, and annotated it with a few window functions. I got a most surprising result when the filter is on fields in a related model and it turns out this lies in the structure of the SQL.

I asked the question here:

https://stackoverflow.com/questions/54388936/using-django-window-functions-on-a-filtered-queryset

mainly because it supports nice layout and captures responses in nice way. The issue is explained there in some detail.

I have in the interim found a work around to meet my needs using slightly different query again, but am still puzzled about this question as it seems fairly prosaic and normal issue, the need to SELECT not from a TABLE but the result of another SELECT. Subqueries speak a little to this but not in a general way that I can seem to manipulate to produce the desired query (the third on cited on the stackoverflow question).

Regards,

Bernd.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f3d7368e-47ec-4ed2-b10e-105a6601e9c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment