Advertisement
cicwak

Untitled

Feb 7th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. SELECT "profiles_follow"."follow_to_id", CASE WHEN "profiles_follow"."follow_from_id" = 1 THEN COUNT("profiles_follow"."follow_to_id") ELSE NULL END AS "cnt" FROM "profiles_follow" GROUP BY "profiles_follow"."follow_to_id", "profiles_follow"."follow_from_id" ORDER BY "cnt" DESC LIMIT 100
  2. Есть такой запрос, нужно убрать строчку ..."profiles_follow"."follow_from_id"...(перед ORDER BY)
  3.  
  4. result = (Follow.objects
  5. .values("follow_to", "follow_from")
  6. .annotate(cnt=Count("follow_to"))
  7. .order_by("-cnt")
  8. .filter(follow_to_id__in=[2, 3])
  9. [:100]
  10. )
  11. При вот таком запросе, может кто знает как это решается?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement