Select 按特定属性的最高值选择集合的元素
我的数据库中存储了以下格式的多个文档:Select 按特定属性的最高值选择集合的元素,select,collections,orientdb,Select,Collections,Orientdb,我的数据库中存储了以下格式的多个文档: { "text": "foo", "items": [{ "num": 1, "value": 1.1 }, { "num": 42, "value": 3.14 }] } { "text": "bar", "items": [{ "num": 3, "value": 5.0 }] } 我想从每个文档中
{
"text": "foo",
"items": [{
"num": 1,
"value": 1.1
}, {
"num": 42,
"value": 3.14
}]
}
{
"text": "bar",
"items": [{
"num": 3,
"value": 5.0
}]
}
我想从每个文档中检索具有最高“num”的项的“text”和“value”。在这个例子中,我的结果是:
{
"text": "foo",
"value": 3.14
}
{
"text": "bar",
"value": 5.0
}
有没有办法用OrientDB解决这个问题?我试过用这些记录 我使用了这个查询
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
我得到
致以最良好的祝愿,
亚历山德罗