I have a table sales with all the column has varchar as datatype.
Name items
Dave {"item1": {"product": apple, "cost": 120}, "item2": {"product": orange, "cost": 80}}
Nick
Jack {"item1": {"product": melon, "cost": 100}, "item2": {"product": berries, "cost": 240}}
I goal is to split the column items as below using SELECT statement
Name items1_product items1_cost items2_product items2_cost
Dave apple 120 orange 80
Nick
Jack melon 100 berries 240
I tried to convert the datatype of items to Json by "select items::JSONB from sales " and I am getting error, type "jsonb" does not exist;
Is there any other way we can achieve this ?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…