# Replied to topics in a certain category, but exclude replies to own topics

**URL:** https://meta.discourse.org/t/replied-to-topics-in-a-certain-category-but-exclude-replies-to-own-topics/276724
**Category:** Data & reporting
**Tags:** sql-triggered-badge
**Created:** [24.Октябрь.2015 16:09:18 UTC](https://meta.discourse.org/t/replied-to-topics-in-a-certain-category-but-exclude-replies-to-own-topics/276724 "2015-10-24T16:09:18Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [28.Октябрь.2015 00:04:07 UTC](https://meta.discourse.org/t/replied-to-topics-in-a-certain-category-but-exclude-replies-to-own-topics/276724/2 "2015-10-28T00:04:07Z")

</div>

I need something similar. For now I use this code, trigger daily:

> [@Badge for replies in a specific category](https://meta.discourse.org/t/badge-for-replies-in-a-specific-category/276730/2):
>
> SELECT p.user\_id user\_id, min(p.id) post\_id, min(p.created\_at) granted\_at  
> FROM badge\_posts p  
> JOIN topics t ON p.topic\_id = t.id  
> WHERE t.category\_id = (SELECT id FROM categories WHERE slug = ‘introductions’)  
> GROUP BY p.user\_id

And this is the problem:

> [@nstemp](#):
>
> Of course this has to avoid replies in your own topic.

Users that start topics inside particular category **must be excluded** from count.  
We have a little number of users that write a lot of posts in a single topic only to reply a single question ☹

---

_[View the full topic](https://meta.discourse.org/t/replied-to-topics-in-a-certain-category-but-exclude-replies-to-own-topics/276724)._
