How to order by COUNT(*) of unique entries in GROUP BY?
1
vote
2
answers
240
views
I search through a tag_map as
SELECT ArticleID,COUNT(*) AS C FROM WordMap
WHERE WordID IN(
SELECT WordID FROM Words WHERE Word IN ('word1', 'word2')
)
GROUP BY ArticleID
ORDER BY C DESC
I want to get article ids in which all words (here word1 and word2) appear first.
The above query returns in order of the number (e.g., if word1 appears 100 times).
NOTE: WordMap table is huge, and this is the reason I went for sub-query rather than JOIN.
Asked by Googlebot
(4551 rep)
Oct 9, 2020, 07:28 AM
Last activity: Jun 8, 2025, 03:09 PM
Last activity: Jun 8, 2025, 03:09 PM