I have a record that looks like this:
{
"id": 93824701,
"lines": [
{"number": 1, "unit_price": 9.77},
{"number": 2, "unit_price": 8.36}
]
}
From the query:
select * from sales where sale @> '{"id": 93824701}'::jsonb;
How do I calculate the sum of all the unit_prices elements (in SQL), so that the result would be 18.13?