Answer the question
In order to leave comments, you need to log in
How to make a SQL query with INNER JOIN in Django via ORM?
Here's how to make such a simple, seemingly request, through the ORM?
SELECT TAB2.option, Count(TAB1.id) AS CountObj
FROM TAB1 INNER JOIN TAB2 ON TAB1.Link = TAB2.id
GROUP BY TAB2.option
ORDER BY Count(TAB1.id) DESC;
Answer the question
In order to leave comments, you need to log in
annotate will help you
Read more here: https://docs.djangoproject.com/en/dev/topics/db/ag... Seems
like a good example with annotate and sorting by count(): stackoverflow.com/questions/1396264/ how-to-sort-by...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question