OrientDB Create GroupBy Table

43 views Asked by At

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

1

There are 1 answers

2
Michela Bonizzi On BEST ANSWER

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