我怎样才能使这个查询在postgresql上工作?

时间:2019-06-13 15:53:02

标签: postgresql postgresql-9.3

有人知道如何适应此查询,以便它在Postgresql中工作吗?函数add_months显然不存在。非常感谢你!

WITH monthly_activity AS (SELECT date_trunc('month', "Date"::date) AS "month", "Company ID"
FROM "DWH_rollup".appointments_totals)

SELECT last_month."month" + add_months(last_month."month", 1), COUNT(DISTINCT last_month."Company ID")
FROM monthly_activity last_month
JOIN monthly_activity this_month
ON this_month."Company ID" = last_month."Company ID" 
AND this_month."month" = add_months(last_month."month", 1)
WHERE this_month."Company ID" is NULL
GROUP BY 1

0 个答案:

没有答案