# ユーザーバッジのカウントとバッジ名のフィルター

**URL:** <https://meta.discourse.org/t/user-badge-counts-with-badge-name-filter/168098>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [2020 年 10 月 19 日午後 2:27 UTC](https://meta.discourse.org/t/user-badge-counts-with-badge-name-filter/168098 "2020-10-19T14:27:15Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![alefattorini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alefattorini/32/119928_2.png) [@alefattorini](https://meta.discourse.org/u/alefattorini)\
**Post date:** [2020 年 10 月 19 日午後 2:27 UTC](https://meta.discourse.org/t/user-badge-counts-with-badge-name-filter/168098/1 "2020-10-19T14:27:15Z")

</div>

> [@SidV](#):
>
> これを試してみてください：
> 
> ```sql
> -- [params]
> -- int :posts = 100
> -- int :top = 10
> SELECT u.username, count(ub.id) as "Badges"
> FROM user_badges ub, users u, user_stats us
> WHERE u.id = ub.user_id
> AND u.id = us.user_id
> AND us.post_count > :posts
> AND (u.admin = 'f' AND u.moderator = 'f')
> GROUP BY u.username
> ORDER BY count(ub.id) desc
> LIMIT :top
> 
> ```

特定のバッジで絞り込むにはどうすればよいですか？そのバッジを獲得した回数を数える必要があります。  
例：「Howto Writer バッジ」の場合、誰が最も多くの Howto を書いたかを知り、ランキングを作成したいです。

---

_[View the full topic](https://meta.discourse.org/t/user-badge-counts-with-badge-name-filter/168098)._
