# Query to create some groups based on activity

**URL:** <https://meta.discourse.org/t/query-to-create-some-groups-based-on-activity/277156>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [August 30, 2023, 9:50am UTC](https://meta.discourse.org/t/query-to-create-some-groups-based-on-activity/277156 "2023-08-30T09:50:27Z")\
**Posts on this page:** 1\
**Showing post:** 9

<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:** [September 4, 2023, 11:12am UTC](https://meta.discourse.org/t/query-to-create-some-groups-based-on-activity/277156/9 "2023-09-04T11:12:44Z")

</div>

> [@JammyDodger](#):
>
> Just to check, are you looking for Likes and Posts Read _all time_ or are those counts for within the past year as well?

All time for likes and post read (the first is to focus on good contributions not just posts, the second one is to balance it)  
The minimum of post is only within the past year, it’s a parameter to understand if members are still consistently alive.

> [@merefield](#):
>
> These look suspiciously like existing Trust Level groups (and the population of those is automated by similar measures) - why don’t you just amend the existing thresholds and have it all done for you?

It could be a good way but in my case I should heavily modify TL1 TL2 and TL3 and need to keep into account the limitations below

> [@JammyDodger](#):
>
> I can see the advantages of making custom ones. For instance, only TL3 relies on minimum engagement over time. So something like this could also drop people from each custom group if their engagement drops over the year.
> 
> They also wouldn’t be tied to the stock abilities and could take advantage of group-enabled features or specific premium categories.

> [@pfaffman](#):
>
> The automation script will now add people to a group if they get a badge. If you can use custom sql for badges then you can automate it, but it does sound like trust levels

Sorry I can’t get it, should I use a badge?  
Uhm how can I modify the query above to insert it into a badge?

---

_[View the full topic](https://meta.discourse.org/t/query-to-create-some-groups-based-on-activity/277156)._
