# Posts per category (with deleted and without deleted)

**URL:** https://meta.discourse.org/t/posts-per-category-with-deleted-and-without-deleted/275010
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [July 17, 2017, 7:02pm UTC](https://meta.discourse.org/t/posts-per-category-with-deleted-and-without-deleted/275010 "2017-07-17T19:02:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [July 17, 2017, 7:02pm UTC](https://meta.discourse.org/t/posts-per-category-with-deleted-and-without-deleted/275010/1 "2017-07-17T19:02:54Z")

</div>

### Posts per category (with deleted and without deleted)

I **think** that by default deleted topics/posts will be included in data-explorer statistics.

Doing some quick experimentation on a category where we delete a lot of stuff:

```plaintext
SELECT count(*) from topics 
WHERE category_id=40

```

returns 799

And then, deliberately excluding deleted topics

```plaintext
SELECT count(*) from topics 
WHERE category_id=40
AND deleted_at is null

```

returns 416.

So to get the statistics you want, I think you can just run the query without checking `deleted_at`

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [July 17, 2017, 7:03pm UTC](https://meta.discourse.org/t/posts-per-category-with-deleted-and-without-deleted/275010/2 "2017-07-17T19:03:35Z")

</div>

Interesting…I assumed (likely incorrectly) that deleted topics were not included. Thanks!
