On Monday 22 May 2017 15:26:59 Todor Velichkov wrote:
> Hello, Дмитрий,
> you can try this one, but w/o further optimizations it may be a very
> slow query.
> 
> qs = Product.objects.filter(
>     #Where score is greater or equal
>     #to the 4th max score from its group
>     score__gte=Subquery(
>         (Product.objects
>             .filter(brand=OuterRef('brand'))
>             .values('score')
>             .order_by('-score')[3:4]
>         )
>     )
> ).order_by('-score')

Yeah, that's how I read it too. But the code says score is on Brand model, not 
Product. 
Which is correct?
-- 
Melvyn Sopacua

-- 
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+unsubscr...@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/1888330.h8aJiHRcfu%40devstation.
For more options, visit https://groups.google.com/d/optout.

Reply via email to