Show top users with most posts created using a tag

Hi community!

I want to get the users with most topics created in each tag category.
For example the list of users with most posts on this community using the data-explorer tag.
I tried a lot with my rusty SQL skills but couldn’t get it right, any help is appreciated!

Thanks in advance :slight_smile:

1 Like

Would something like this work?

-- [params]
-- string :tag_name


SELECT t.user_id,
       count(t.user_id) AS count
FROM topic_tags tt
JOIN topics t ON t.id = tt.topic_id
JOIN tags tg ON tg.id = tt.tag_id
WHERE t.deleted_at IS NULL
AND t.archetype = 'regular'
AND tg.name = :tag_name
GROUP BY t.user_id
ORDER BY count DESC 

LIMIT 10
4 Likes

Thanks @JammyDodger,

Exactly what I was looking for :star_struck:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.