postgresql - 如何让这个查询在 postgresql 上工作?
问题描述
有谁知道如何调整这个查询以便它在 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
解决方案
推荐阅读
- c# - 在windows xp c# windows窗体中连接到本地数据库
- c# - 在 docker 容器中收到组装错误,但在本地机器上没有
- sql - 如何计算Oracle sql中的变化
- cuda - Asynchronous texture object allocation in multi-GPU code
- c# - 如何以 2 种不同的形式链接 2 个标签
- ibm-cloud - IBM Bluemix 中的 Node-red 在睡眠后启动时崩溃(精简帐户)
- import - 如何使用 PCL io::loadPLYFile 导入 .ply 文件?
- c# - 如何注册我的 Visual Studio 扩展来运行事件?
- java - 按钮按下导致应用程序停止,Textview 更改失败?
- c# - DotNetCore.NPOI 总是创建损坏的文件