有人知道如何适应此查询,以便它在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