# 按（回复+活动）组合对帖子进行排序或排列

**URL:** <https://meta.discourse.org/t/sort-or-order-post-with-combination-of-both-replies-activity/252165>\
**Category:** Product Support\
**Created:** [2023 年1 月 18 日 12:22 UTC](https://meta.discourse.org/t/sort-or-order-post-with-combination-of-both-replies-activity/252165 "2023-01-18T12:22:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

作者： ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
发布日期： [2023 年1 月 22 日 20:39 UTC](https://meta.discourse.org/t/sort-or-order-post-with-combination-of-both-replies-activity/252165/4 "2023-01-22T20:39:30Z")

</div>

在尝试为此创建查询时，我想到高级搜索过滤器中有几个选项可能也有用。在其中，您可以设置最大帖子数、之前或之后的日期，以及添加它们是否已打开，将其限制为特定类别，等等。这对更多人来说可能是更易于访问的方式来获得与您想要的东西类似的东西。

但是，我认为数据浏览器查询也可以完成这项工作，并且根据您的需要，可能更具可定制性。也许是这样的：

```sql

-- [params]
-- int :number_of_posts

SELECT t.category_id,
       t.id AS topic_id,
       t.created_at::date
FROM topics t
WHERE t.posts_count < :number_of_posts
AND t.archetype = 'regular'
AND t.closed = false
AND t.deleted_at IS NULL
AND t.created_at >= CURRENT_DATE - INTERVAL '1 WEEK'
ORDER BY t.created_at DESC

```

这将提取过去一周内创建的所有回复少于 x 条的帖子（未关闭、未删除、非私人消息）。

这是否接近您所想的？

---

_[View the full topic](https://meta.discourse.org/t/sort-or-order-post-with-combination-of-both-replies-activity/252165)._
