简体   繁体   中英

OrientDB Create GroupBy Table

For example I have following table

[id, V1, V2]
[A , 1 , 5]
[A , 2 , 4]
[A , 3 , 3]
[A , 4 , 2]
[B , 9 , 6]
[B , 8 , 7]
[B , 7 , 8]
[B , 6 , 9]

I Want to create query with following result

[id,     V1`   ,    V2`  ] ]
[A , [1,2,3,4] , [5,4,3,2] ]
[B , [9,8,7,6] , [6,7,8,9] ]

OR

[id, min , max ]
[A , [1] , [5] ]
[B , [6] , [9] ]

How this query can be costructed ? I allready tried a lot of options but failed.

Any help will be appriciated. Thanks in advance

Try this:

select id, $a.V1 as V1, $a.V2 as V2 from <class name>
let $a = (select from <class name> where $parent.current.id = id)
group by id

Hope it helps

Regards

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM