Supposedly there's a set of records where each record looks like the following:
{
"total": 300,
"items": [
{
"id": "item1",
"amount": 100
},
{
"id": "item2",
"amount": 200
},
]
}
Is it possible to do a sum of all totals and items with id = "item1"?
So basically, smth like this (i know that query is ultimately incorrect, but just to show the idea):
select sum(total) as total, sum(items(id="item1").amount) as item1Amount
from MyRecord
Got the answer from GitHub's project. Apparently my initial hypothetical query was quite close to what it should be.
Here's the answer:
select sum(total) as total, sum(items[id="item1"].amount) as item1Amount
from MyRecord
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.