# Filter mods/bots from post\_count?

**URL:** https://meta.discourse.org/t/filter-mods-bots-from-post-count/243101
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [October 27, 2022, 4:58pm UTC](https://meta.discourse.org/t/filter-mods-bots-from-post-count/243101 "2022-10-27T16:58:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Matt0x01](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/matt0x01/32/264811_2.png) [@Matt0x01](https://meta.discourse.org/u/Matt0x01)
#### Post date: [October 27, 2022, 4:58pm UTC](https://meta.discourse.org/t/filter-mods-bots-from-post-count/243101/1 "2022-10-27T16:58:52Z")

</div>

Hey,

I’m trying to filter out moderators/bots out of post\_count. I’ve tried using NOT IN as shown below. I’ve tried with the user ids as well but nothing seems to work. Any help?

> SELECT  
> distinct(t.id) as topic\_id,  
> t.posts\_count as comments
> 
> FROM topics t  
> LEFT JOIN posts p ON t.id = p.topic\_id and t.user\_id = p.user\_id  
> LEFT JOIN users u ON u.id = t.id
> 
> WHERE t.category\_id IN (20,21,5,7,9,11)  
> AND t.id NOT IN (17,19,21,23,6300,6301)  
> – AND strpos(t.title, ‘About the’) != 0  
> –AND u.username NOT IN (‘system’, ‘river’, ‘Pearson’)  
> order by t.id asc

---

<div class="post-metadata">

### Author: ![Matt0x01](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/matt0x01/32/264811_2.png) [@Matt0x01](https://meta.discourse.org/u/Matt0x01)
#### Post date: [November 2, 2022, 4:27pm UTC](https://meta.discourse.org/t/filter-mods-bots-from-post-count/243101/2 "2022-11-02T16:27:48Z")

</div>

Still need help with this. Not sure if there’s any other information thats needed for assistance.

The query is supposed to count all unique posters under a topic excluding users who are mods/admin, as well as bots. However, I am not sure how to filter out staff and bots from post\_count.

Hopefully this makes it more clear with how its supposed to work and what isnt working.
