# トップクオリティメンバークエリからグループを除外

**URL:** <https://meta.discourse.org/t/exclude-groups-from-top-quality-members-query/156510>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [2020 年 7 月 1 日午後 6:42 UTC](https://meta.discourse.org/t/exclude-groups-from-top-quality-members-query/156510 "2020-07-01T18:42:12Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![outofthebox](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outofthebox/32/83708_2.png) [@outofthebox](https://meta.discourse.org/u/outofthebox)\
**Post date:** [2020 年 7 月 1 日午後 6:42 UTC](https://meta.discourse.org/t/exclude-groups-from-top-quality-members-query/156510/1 "2020-07-01T18:42:12Z")

</div>

こんにちは

このクエリから特定のグループを除外する方法について、ご助言いただけますでしょうか？

```
SELECT 
    sum(p.score) / count(p) as "平均スコア", 
    count(p.id) as post_count, 
    p.user_id
FROM posts p
JOIN users u ON u.id = p.user_id
WHERE p.created_at >= CURRENT_DATE - INTERVAL '3 month'
  AND u.active
GROUP by user_id, u.views
HAVING count(p.id) > 40
ORDER BY sum(p.score) / count(p) DESC
LIMIT 100

```

ご回答を心よりお待ちしております。

---

_[View the full topic](https://meta.discourse.org/t/exclude-groups-from-top-quality-members-query/156510)._
