# How can I count posts in last month by a specific group of users?

**URL:** https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [11월 4, 2016, 10:12오전 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489 "2016-11-04T10:12:49Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![alefattorini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alefattorini/32/119928_2.png) [@alefattorini](https://meta.discourse.org/u/alefattorini)
#### Post date: [11월 4, 2016, 10:12오전 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489/1 "2016-11-04T10:12:49Z")

</div>

Do you have any query for [Data explorer](https://meta.discourse.org/t/32566?silent=true)?  
I need to calculate the impact of my ambassador group

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [11월 8, 2016, 9:54오후 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489/3 "2016-11-08T21:54:22Z")

</div>

Is this close?

> [@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…

---

<div class="post-metadata">

### Author: ![HAWK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hawk/32/86627_2.png) [@HAWK](https://meta.discourse.org/u/HAWK)
#### Post date: [11월 8, 2016, 11:03오후 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489/4 "2016-11-08T23:03:06Z")

</div>

That one doesn’t allow you to specify the group id as a parameter

---

<div class="post-metadata">

### Author: ![alefattorini](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alefattorini/32/119928_2.png) [@alefattorini](https://meta.discourse.org/u/alefattorini)
#### Post date: [11월 9, 2016, 9:55오전 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489/5 "2016-11-09T09:55:13Z")

</div>

Yes man, how can I filter for group\_id?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [11월 9, 2016, 7:14오후 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489/6 "2016-11-09T19:14:07Z")

</div>

I think a JOIN with the group\_users table ON user\_id WHERE group\_id should do it.

```plaintext
group_users
id serial primary key 
group_id integer fkey groups 
user_id integer fkey users 
created_at timestamp 
updated_at timestamp 
owner boolean default false 
notification_level integer default 2 

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [3월 27, 2019, 12:24오전 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489/7 "2019-03-27T00:24:28Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [5월 25, 2022, 3:54오후 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489/8 "2022-05-25T15:54:51Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8월 14, 2023, 11:34오후 UTC](https://meta.discourse.org/t/how-can-i-count-posts-in-last-month-by-a-specific-group-of-users/52489/9 "2023-08-14T23:34:46Z")

</div>


