# 데이터 탐색기 쿼리: 답변이 없는 게시물 찾기

**URL:** <https://meta.discourse.org/t/data-explorer-query-find-posts-without-replies/179767>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [2월 15, 2021, 11:49오전 UTC](https://meta.discourse.org/t/data-explorer-query-find-posts-without-replies/179767 "2021-02-15T11:49:43Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Ed\_Bobkov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_bobkov/32/200014_2.png) [@Ed\_Bobkov](https://meta.discourse.org/u/Ed_Bobkov)\
**Post date:** [2월 15, 2021, 11:49오전 UTC](https://meta.discourse.org/t/data-explorer-query-find-posts-without-replies/179767/1 "2021-02-15T11:49:43Z")

</div>

다음 주제를 참고했습니다: [How to find topics without a reply from someone other than the topic owner?](https://meta.discourse.org/t/how-to-find-posts-not-first-posts-and-not-topics-without-a-reply/179760)

이 쿼리를 작성했지만 제 경우 문제가 발생합니다.

```plaintext
PG::UndefinedTable: ERROR: missing FROM-clause entry for table "t"
LINE 31: AND t.category_id = ANY ('{48,23}'::int[])

```

쿼리 코드는 다음과 같습니다:

```plaintext
-- [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 
p.created_at,
p.topic_id,
p.id as post_id,
p.like_count,
p.post_number,
p.reply_count
FROM posts p
LEFT JOIN post_search_data psd ON psd.post_id = p.id
RIGHT JOIN query_period qp
    ON p.created_at >= qp.period_start
        AND p.created_at <= qp.period_end
WHERE 
      reply_count = 0
      AND post_number != 0
	  AND t.category_id = ANY ('{48,23}'::int[])

```

두 가지 질문이 있습니다:

1. Categories 테이블을 어떻게 정의해야 이 오류를 해결할 수 있을까요?
2. 기간을 현재 날짜의 하루 후부터 시작하려면 어떻게 해야 하나요?

---

_[View the full topic](https://meta.discourse.org/t/data-explorer-query-find-posts-without-replies/179767)._
