# 回答を解決するバッジを追加

**URL:** https://meta.discourse.org/t/add-badge-to-solve-answer/79126
**Category:** Feature
**Tags:** solved
**Created:** [2018 年 1 月 26 日午後 10:56 UTC](https://meta.discourse.org/t/add-badge-to-solve-answer/79126 "2018-01-26T22:56:41Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [2018 年 1 月 26 日午後 11:05 UTC](https://meta.discourse.org/t/add-badge-to-solve-answer/79126/2 "2018-01-26T23:05:22Z")

</div>

Are you talking of this query?

```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
                     value IS NOT NULL 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)

```

You need to follow this topic: [Enable Badge SQL](https://meta.discourse.org/t/badge-sql-can-no-longer-be-edited-by-default/47894)  
Then create a new badge in `your-site.com/admin/badges`

---

_[View the full topic](https://meta.discourse.org/t/add-badge-to-solve-answer/79126)._
