# Abzeichen funktioniert nicht

**URL:** <https://meta.discourse.org/t/badge-not-working/39426>\
**Category:** Data & reporting\
**Tags:** sql-triggered-badge\
**Created:** [11. Februar 2016 um 20:52 UTC](https://meta.discourse.org/t/badge-not-working/39426 "2016-02-11T20:52:25Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![zainab](https://avatars.discourse-cdn.com/v4/letter/z/258eb7/32.png) [@zainab](https://meta.discourse.org/u/zainab)\
**Post date:** [11. Februar 2016 um 20:52 UTC](https://meta.discourse.org/t/badge-not-working/39426/1 "2016-02-11T20:52:25Z")

</div>

Hi,

I’m not sure if I’m posting in the correct category.

anyway theres a badge for the forum called help desk and its not working, users get 10 accepted answers yet they dont get a badge

here’s the SQL code:

```plaintext
SELECT p.user_id, p.id post_id, p.updated_at granted_at
FROM badge_posts p
WHERE p.post_number > 1 AND 
p.id IN (
SELECT post_id FROM (
SELECT pc.post_id, row_number() 
OVER (PARTITION BY p1.user_id ORDER BY pc.created_at) as rnum
FROM post_custom_fields pc
JOIN badge_posts p1 ON p1.id = pc.post_id
JOIN topics t1 ON p1.topic_id = t1.id
WHERE name = 'is_accepted_answer' AND
p1.user_id <> t1.user_id AND 
(
:backfill OR 
p1.user_id IN (
select user_id from posts where p1.id IN (:post_ids)
)
)
) X WHERE rnum = 1)

```

---

_[View the full topic](https://meta.discourse.org/t/badge-not-working/39426)._
