# 特定月の「解決済み」投稿を検索

**URL:** <https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674>\
**Category:** Data & reporting\
**Tags:** solved, sql-query\
**Created:** [2019 年 3 月 27 日午前 8:04 UTC](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674 "2019-03-27T08:04:26Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![csmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csmu/32/124581_2.png) [@csmu](https://meta.discourse.org/u/csmu)\
**Post date:** [2019 年 3 月 29 日午後 10:03 UTC](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674/4 "2019-03-29T22:03:05Z")

</div>

> [@user2](#):
>
> if I even know where to start

Here is a starting point.

```sql
-- [params]
-- int :months_ago = 1

WITH query_period AS
(SELECT date_trunc('month', CURRENT_DATE) - INTERVAL ':months_ago months' AS period_start,
                                                    date_trunc('month', CURRENT_DATE) - INTERVAL ':months_ago months' + INTERVAL '1 month' - INTERVAL '1 second' AS period_end)
select posts.*
from posts
inner join ( 
	select topic_id, value::int accepted_answer_post_id 
	from topic_custom_fields 
	where name = 'accepted_answer_post_id'
	order by name 
) solved_by_post
on posts.id = solved_by_post.accepted_answer_post_id
inner join query_period
on posts.created_at >= query_period.period_start
AND posts.created_at <= query_period.period_end
order by posts.created_at desc 

```

[solved-topics-in-month.dcquery (1).json](https://global.discourse-cdn.com/meta/original/3X/a/c/accd87e7ced0612d0378897168f15c87eb8c2d0d.json) (1.1 KB)

---

_[View the full topic](https://meta.discourse.org/t/find-posts-solved-in-specific-month/112674)._
