我有一个json数组-
[{id:1,quantity:100},{id:2,quantity:25},{id:3,quantity:68}]
如何使用postgres中的查询将其转换为以下内容-
Id |Quantity
-----------------
1 |100
2 |25
3 |68
如果有可能,我想知道如何
答案 0 :(得分:2)
select t ->> 'id' as id, t ->> 'quantity' as quantity
from jsonb_array_elements('[{"id":1,"quantity":100},{"id":2,"quantity":25},{"id":3,"quantity":68}]') as t