0

我在下面有以下 PostgreSQL 查询。如果我删除一行AND r.type = "long_form",它工作正常。我不确定为什么 PostgreSQL 不喜欢这条线:

SELECT  TRUNC(DATE_PART('day', CURRENT_DATE - r.created_at )/7)  AS weeks_ago,
        date(min(r.created_at)) AS "Date Start",
        date(max(r.created_at)) AS "Date End",
        count(*) as  "Reviews in Cohort",
        AVG(has_note::int) as "Reviews w 1 or more Notes Ratio"
FROM (SELECT r.id, r.created_at,
             ( MAX(rn.note) IS NOT NULL ) as has_note
      FROM reviews f JOIN
           reviewss_notes rn
           ON r.id = rn.review_id

            WHERE r.completed_at IS NOT NULL
                    AND r.created_at > '2019-01-01'
                    AND r.type = "long_form"

            GROUP BY r.id
     ) f
GROUP BY weeks_ago
ORDER BY weeks_ago DESC;

这是查询中导致问题的行:

AND r.type = "long_form"

该表的设计包括一列:

在此处输入图像描述

我在这里做错了什么?

4

1 回答 1

2

检查您的引号字符...

AND r.type = 'long_form'

使用单引号表示字符串常量。

于 2019-08-15T18:19:10.613 回答