# 主题浏览量徽章查询

**URL:** <https://meta.discourse.org/t/badge-query-for-topic-views/228174>\
**Category:** Data & reporting\
**Tags:** sql-triggered-badge\
**Created:** [2022年五月26日 15:36 UTC](https://meta.discourse.org/t/badge-query-for-topic-views/228174 "2022-05-26T15:36:37Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![not-ethan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/not-ethan/32/282617_2.png) [@not-ethan](https://meta.discourse.org/u/not-ethan)\
**Post date:** [2022年五月26日 16:08 UTC](https://meta.discourse.org/t/badge-query-for-topic-views/228174/2 "2022-05-26T16:08:33Z")

</div>

我找到了这个徽章查询。

```SQL
SELECT p.user_id, min(p.created_at) granted_at, MIN(p.id) post_id
FROM badge_posts p
JOIN topics t ON t.id = p.topic_id
WHERE category_id = (
  SELECT id FROM categories WHERE name ilike 'Technology'
) AND p.post_number = 1
AND views >= 10
and (:backfill OR ( p.id IN (:post_ids) ))
GROUP BY p.user_id

```

请注意，这不是我的。这是[OP](https://meta.discourse.org/t/what-cool-badge-queries-have-you-come-up-with/18978/212?u=how_to_roblox)。

---

_[View the full topic](https://meta.discourse.org/t/badge-query-for-topic-views/228174)._
