最佳答案
您必须在 FROM
子句中包含 cte
,而不是 FROM tempstockpos WHERE .... AND tempstockpos.batchid = cte.batchid
,例如:
FROM tempstockpos, cte WHERE .... AND tempstockpos.batchid = cte.batchid
或者最好是更干净、更具可读性:
FROM tempstockpos INNER JOIN cte ON tempstockpos.batchid = cte.batchid WHERE ....
关于postgresql - 错误: missing FROM-clause entry for table "cte" while executing query in CTE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24969635/