# Bulk remove users

**URL:** <https://meta.discourse.org/t/bulk-remove-users/53450>\
**Category:** Product Support\
**Created:** [November 27, 2016, 10:32pm UTC](https://meta.discourse.org/t/bulk-remove-users/53450 "2016-11-27T22:32:00Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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:** [May 21, 2017, 8:13am UTC](https://meta.discourse.org/t/bulk-remove-users/53450/7 "2017-05-21T08:13:34Z")

</div>

One of my sites uses SSO and we’re looking to remove users that have never posted and haven’t been seen in a year (to avoid killing users who are just quiet). Is this query valid in the rails console?

```plaintext
User.joins(:user_stat).where("user_stats.post_count = 0 AND previous_visit_at <= '2016-05-20'::timestamp").destroy_all

```

---

_[View the full topic](https://meta.discourse.org/t/bulk-remove-users/53450)._
