我想做的是将29.0和34.65相加,并按P_id分组。
数据:
我尝试使用这里提到的解决方案。
然而,我遇到了一个错误,显示“无法解构标量”。
请问有人可以告诉我如何解析我正在寻找的值吗?
Table: transaction_items
Column name: Debits, P_id
Column data type: text, text
数据:
借方
[{"amount":29.0,"description":"Fee_Type_1"}
[{"amount":"34.65","description":"Fee_Type_1"}
产品编号
16
16
我尝试使用这里提到的解决方案。
select transaction_line_items.P_id,
each_attribute ->> 'amount' Rev
from transaction_line_items
cross join json_array_elements(to_json(Debits)) each_section
cross join json_array_elements(each_section -> 'attributes') each_attribute
where (each_attribute -> 'amount') is not null;
然而,我遇到了一个错误,显示“无法解构标量”。
请问有人可以告诉我如何解析我正在寻找的值吗?