# 查看新用户（及其他信任等级）最常发帖的类别

**URL:** <https://meta.discourse.org/t/see-what-categories-new-users-other-trust-levels-post-in-most/80494>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [2018年二月13日 19:49 UTC](https://meta.discourse.org/t/see-what-categories-new-users-other-trust-levels-post-in-most/80494 "2018-02-13T19:49:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bts](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bts/32/184556_2.png) [@bts](https://meta.discourse.org/u/bts)\
**Post date:** [2018年二月13日 21:00 UTC](https://meta.discourse.org/t/see-what-categories-new-users-other-trust-levels-post-in-most/80494/2 "2018-02-13T21:00:14Z")

</div>

Sounds like a job for the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) plugin! Very useful, you can learn more about it here:

> [@Discourse Data Explorer](https://meta.discourse.org/t/data-explorer-plugin/32566):
>
> discourse2Summary Discourse [Data Explorer](https://meta.discourse.org/t/32566?silent=true) allows you to make SQL queries against your live database, allowing for up-to-the-minute stats reporting.open_bookInstall Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately.information_source If you’re looking for examples or support for any custom queries, you can find lots of topics in our #Data & reporting category under the #sql-query tag. If there’s not one to suit your pa…

Here’s a stab at a SQL query that does something like this — it takes `trust_level` as a parameter, and then returns a sorted list of the # of posts created in each category by users w/ that trust level (disclaimer, I’m a SQL novice, modify as needed!):

```plaintext
-- [params]
-- int :trust_level = 1

WITH topic_categories AS
    (SELECT
        t.id topic_id,
        t.user_id,
        t.created_at,
        t.score,
        c.id category_id,
        c.name category_name
    FROM
        topics t
    LEFT JOIN categories c
    ON t.category_id = c.id
    )

SELECT 
    count(tc.*) count,
    tc.category_id
FROM
    users u
LEFT JOIN topic_categories tc
ON u.id = tc.user_id
WHERE 
    tc.created_at IS NOT NULL
    AND tc.category_id IS NOT NULL
    AND u.trust_level = :trust_level
GROUP BY 
    tc.category_id
ORDER BY count DESC

```

---

_[View the full topic](https://meta.discourse.org/t/see-what-categories-new-users-other-trust-levels-post-in-most/80494)._
