# Request: Custom Badge SQL for total Like count

**URL:** <https://meta.discourse.org/t/request-custom-badge-sql-for-total-like-count/226489>\
**Category:** Data & reporting\
**Tags:** sql-triggered-badge\
**Created:** [May 9, 2022, 2:40am UTC](https://meta.discourse.org/t/request-custom-badge-sql-for-total-like-count/226489 "2022-05-09T02:40:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [May 13, 2022, 10:38am UTC](https://meta.discourse.org/t/request-custom-badge-sql-for-total-like-count/226489/2 "2022-05-13T10:38:40Z")

</div>

Hello and welcome @rapphann 🙂

I’m afraid I’m not a SQL master either 🙂 But I would think it would be something like this:

```plaintext
SELECT us.user_id, current_timestamp AS granted_at 
FROM user_stats AS us 
WHERE us.likes_received >= 100 
AND us.likes_given >= 100
AND (:backfill OR us.user_id IN (:user_ids))

```

---

_[View the full topic](https://meta.discourse.org/t/request-custom-badge-sql-for-total-like-count/226489)._
