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

enter image description here

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

enter image description here

best regards, alessandro


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -