# Stats reports on a per-category basis?

**URL:** https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000
**Category:** Data & reporting
**Created:** [April 30, 2020, 11:31pm UTC](https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000 "2020-04-30T23:31:41Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Grayden\_Shand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grayden_shand/32/166586_2.png) [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)
#### Post date: [April 30, 2020, 11:54pm UTC](https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000/2 "2020-04-30T23:54:25Z")

</div>

Check out the [Data Explorer plugin](https://meta.discourse.org/t/data-explorer-plugin/32566).

You can use this to generate reports from SQL queries, here’s a query that will capture some of what you want to track.

```plaintext
-- [params]
-- date :start_date = 2020-04-01
-- date :end_date = 2020-04-29

SELECT c.id category_id, COUNT(DISTINCT(t.id)) topics, COUNT(p.id) posts, sum(p.like_count) likes, sum(p.reads) reads
FROM categories c
INNER JOIN topics t ON (t.category_id = c.id)
INNER JOIN posts p ON (p.topic_id = t.id AND p.post_type = 1)
WHERE p.created_at BETWEEN :start_date AND :end_date
GROUP BY c.id
ORDER BY COUNT(p.id) DESC

```

You can share these reports with groups via the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) UI:  
[![](https://global.discourse-cdn.com/meta/original/3X/1/0/105d438ed47fd63e2a9ab3894cee18e90d9f305b.png) ](https://dl.dropboxusercontent.com/s/z2ftyw94t7l9nvp/Screenshot%202020-04-30%2019.53.20.png?dl=0)

And it will appear in the group page like this:  
[![](https://global.discourse-cdn.com/meta/original/3X/f/d/fda5dbeca6dad491a88c2134dc81cd5f8a2703ff.png) ](https://dl.dropboxusercontent.com/s/bzym022zq642dqx/Screenshot%202020-04-30%2019.52.13.png?dl=0)

---

_[View the full topic](https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000)._
