【发布时间】:2015-03-04 11:08:44
【问题描述】:
我正在尝试加入返回行的表和函数:
SELECT p.id, p.name, f.action, f.amount
FROM person p
JOIN calculate_payments(p.id) f(id, action, amount) ON (f.id = p.id);
此函数为每个 id 返回 0、1 或更多行。 该查询适用于 PostgreSQL 9.3,但在 9.1 上显示以下错误:
ERROR: invalid reference to FROM-clause entry for table "p" HINT: There is an entry for table "p", but it cannot be referenced from this part of the query
我无法将计算从函数移到查询中。
据我了解,我不能使用 JOIN LATERAL,这是 9.3 中的一项新功能。
这个问题有解决办法吗?
【问题讨论】:
标签: sql postgresql join set-returning-functions lateral