# Amending sample Gamification scoring badge

**URL:** https://meta.discourse.org/t/amending-sample-gamification-scoring-badge/275737
**Category:** Data & reporting
**Tags:** gamification, sql-triggered-badge
**Created:** [June 20, 2023, 11:35pm UTC](https://meta.discourse.org/t/amending-sample-gamification-scoring-badge/275737 "2023-06-20T23:35:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [June 20, 2023, 11:35pm UTC](https://meta.discourse.org/t/amending-sample-gamification-scoring-badge/275737/1 "2023-06-20T23:35:03Z")

</div>

```plaintext
SELECT user_id, current_timestamp AS granted_at 
FROM gamification_scores
WHERE (:backfill OR user_id IN (:user_ids))
GROUP BY 1
HAVING SUM(score) > 9000

```

Can that query be limited by year, monthly or three months?

---

<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: [October 8, 2023, 7:52pm UTC](https://meta.discourse.org/t/amending-sample-gamification-scoring-badge/275737/2 "2023-10-08T19:52:02Z")

</div>

I think you could add in something like:

```sql
SELECT user_id, CURRENT_TIMESTAMP AS granted_at 
FROM gamification_scores
WHERE date >= CURRENT_DATE - INTERVAL '1 MONTH'
  AND user_id > 0
  AND (:backfill OR user_id IN (:user_ids))
GROUP BY 1
HAVING SUM(score) > 1000

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [January 25, 2025, 12:55am UTC](https://meta.discourse.org/t/amending-sample-gamification-scoring-badge/275737/3 "2025-01-25T00:55:45Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
