I want to select value from a json array. Eg: The data is in table Data in column name json_col
{
"ABlock": {
"fruits1": [{
"Frt1": "Apple",
"Clr1": "Red",
"Qty1": "14"
}, {
"Frt1": "Grapes",
"Clr1": "Black",
"Qty1": "7"
}],
"fruits2": [{
"Frt2": "Pear",
"Clr2": "Green",
"Qty2": "9"
}, {
"Frt2": "Lemon",
"Clr2": "Yellow",
"Qty2": "5"
}]
}
}
Here I want to select Qty1&Qty2. The code I tried to select just Qty1 is
Select json_value(json_col, '$.ABlock.fruits1[0].Qty1) + ',' + json_value(json_col, '$.ABlock.fruits1[1].Qty1) as qty
from Data;
But I'm getting error as 'invalid number'
The output I should get is: 14 7.