# Different counting methods for Likes: user\_stats vs Badges \[maybe bug\]

**URL:** <https://meta.discourse.org/t/different-counting-methods-for-likes-user-stats-vs-badges-maybe-bug/58145>\
**Category:** UX\
**Created:** [Mars 1, 2017, 12:23 UTC](https://meta.discourse.org/t/different-counting-methods-for-likes-user-stats-vs-badges-maybe-bug/58145 "2017-03-01T00:23:07Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Lutz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lutz/32/65103_2.png) [@Lutz](https://meta.discourse.org/u/Lutz)\
**Post date:** [Mars 1, 2017, 2:39 UTC](https://meta.discourse.org/t/different-counting-methods-for-likes-user-stats-vs-badges-maybe-bug/58145/6 "2017-03-01T14:39:57Z")

</div>

Yes but the badge query gives an other number:

Original Query is

> ```
> SELECT us.user_id, current_timestamp AS granted_at
> FROM user_stats AS us
> INNER JOIN posts AS p ON p.user_id = us.user_id
> WHERE p.like_count > 0
> AND us.likes_given > = 1000
> AND (: backfill OR us.user_id IN (: user_ids))
> GROUP BY us.user_id, us.likes_given
> HAVING COUNT (*) > 500
> 
> ```

And

> ```
> SELECT us.user_id, count (*) cnt_likes_received, us.likes_given
> FROM user_stats AS us
> INNER JOIN posts AS p ON p.user_id = us.user_id
> WHERE p.like_count> 0
> AND us.user_id = 15
> AND us.likes_given >= 1000
> GROUP BY us.user_id, us.likes_given;
> 
> ```

gives  
 ![](https://global.discourse-cdn.com/meta/original/3X/3/3/33cd51f66424284b8569d2b36a4b9833c5516086.png)

---

_[View the full topic](https://meta.discourse.org/t/different-counting-methods-for-likes-user-stats-vs-badges-maybe-bug/58145)._
