# Data explorer query for all active users (Lurkers + Posters)

**URL:** <https://meta.discourse.org/t/data-explorer-query-for-all-active-users-lurkers-posters/188343>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [April 28, 2021, 10:15am UTC](https://meta.discourse.org/t/data-explorer-query-for-all-active-users-lurkers-posters/188343 "2021-04-28T10:15:08Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)\
**Post date:** [April 28, 2021, 10:15am UTC](https://meta.discourse.org/t/data-explorer-query-for-all-active-users-lurkers-posters/188343/1 "2021-04-28T10:15:08Z")

</div>

I’m looking to give our team stats over how many current active users we have, with the following definition of ‘Active User’:

> Users who have either read whilst logged in or posted to our forum over the last year

We have a lot of users on Mailing List Mode who respond via email, so we’ll miss many if we simply gathering the number of readers as per this query:

> [@Active Readers (Since N Days Ago)](https://meta.discourse.org/t/active-readers-since-n-days-ago/275136):
>
> Active Readers (Since N Days Ago) Number of users who have read at least 1 post since N days ago with intervals as ( select n as start\_time, CURRENT\_TIMESTAMP as end\_time from generate\_series(CURRENT\_TIMESTAMP - INTERVAL '30 days', CURRENT\_TIMESTAMP - INTERVAL '1 day', INTERVAL '1 days') n ), latest\_visits as ( select user\_id, max(visited\_at) as visited\_at from user\_visits where posts\_read \> …

I can also get the number who have posted here:

> [@Posts created for period](https://meta.discourse.org/t/posts-created-for-period/275138):
>
> Posts created for period Got what I need (thanks @meglio) so updating this for future posterity. -- [params] -- date :date\_from -- date :date\_to -- int :min\_posts = 1 WITH user\_activity AS ( SELECT p.user\_id, count (p.id) as posts\_count FROM posts p LEFT JOIN topics t ON t.id = p.topic\_id WHERE p.created\_at::date BETWEEN :date\_from::date AND :date\_to::date AND t.deleted\_at IS NULL AND t.visible = TRUE AND t.closed = FALSE AND t.archived = FALSE…

I’m just too dumb to combine them with an OR so we pick up both groups. Can you help?

---

_[View the full topic](https://meta.discourse.org/t/data-explorer-query-for-all-active-users-lurkers-posters/188343)._
