Reputation: 3
I have several documents stored in my database with the following format:
{
"text": "foo",
"items": [{
"num": 1,
"value": 1.1
}, {
"num": 42,
"value": 3.14
}]
}
{
"text": "bar",
"items": [{
"num": 3,
"value": 5.0
}]
}
I want to retrieve from each document the "text" and the "value" of the item with the highest "num". So in this example my result would be:
{
"text": "foo",
"value": 3.14
}
{
"text": "bar",
"value": 5.0
}
Is there any way to solve this problem with OrientDB?
Upvotes: 0
Views: 60
Reputation: 3570
I tried with these records
and I used this query
select rid,items.num as num,items.value as value from (
select @rid,items,$a[0].max as max from test
let $a=(select max(items.num) as max from $parent.$current)
unwind items
)
where items.num=max
I got
Best regards, Alessandro
Upvotes: 1