Select element of collection by highest value of specific attribute -
i have several documents stored in database 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 retrieve each document "text" , "value" of item highest "num". in example result be:
{ "text": "foo", "value": 3.14 } { "text": "bar", "value": 5.0 }
is there way solve problem orientdb?
i tried these records
and used query
select rid,items.num num,items.value value ( select @rid,items,$a[0].max max test let $a=(select max(items.num) max $parent.$current) unwind items ) items.num=max
i got
best regards, alessandro
Comments
Post a Comment