# Data discrepancy in user post counts

**URL:** <https://meta.discourse.org/t/data-discrepancy-in-user-post-counts/177214>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [January 25, 2021, 8:14pm UTC](https://meta.discourse.org/t/data-discrepancy-in-user-post-counts/177214 "2021-01-25T20:14:16Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![hollyw](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@hollyw](https://meta.discourse.org/u/hollyw)\
**Post date:** [January 25, 2021, 8:14pm UTC](https://meta.discourse.org/t/data-discrepancy-in-user-post-counts/177214/1 "2021-01-25T20:14:16Z")

</div>

I’m trying to figure out a potential data discrepancy I’m seeing. I’ve been doing some queries with the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) plugin to get stats on our most-frequently posting users. One query I used was the following:

```plaintext
select u.username, us.post_count
from users u
join user_stats us
on u.id = us.user_id
order by us.post_count desc

```

This was returning, say, 100 posts for a particular user. Then I decided to redo the query a little differently:

```plaintext
select u.username, count(distinct p.id)
from users u
join posts p
on u.id = p.user_id
group by u.username
order by count(distinct p.id) desc

```

This query for that particular user returned 135 posts. And this seems to be the correct number, since it’s actually counting every single post from the posts table, as opposed to relying on the `post_count` field from `user_stats`.

So I’m trying to understand why there would be a discrepancy here. This is for a non-admin, non-mod user, so they don’t have a bunch of admin actions that are appearing as posts. Any ideas why this might be happening?

---

_[View the full topic](https://meta.discourse.org/t/data-discrepancy-in-user-post-counts/177214)._
