我试试这个
select created_at,
sum((json_array_elements(shipping_lines::json) ->> 'price')::float) as shipping_price
from t1
group by 1
它显示错误:
错误:聚合函数调用不能包含集合返回函数调用第 5 行:sum(((json_array_elements(shipping_lines::json) ->> 'price')... ^ 提示:您也许可以移动集合返回函数到 LATERAL FROM 项目中。
如何使用横向从解决此问题?我阅读了这个 PsSQL 文档,但不太了解横向函数