Limit on specific vertex of a match query

17 views
Skip to first unread message

nicolas treiber

unread,
Apr 13, 2017, 8:15:31 AM4/13/17
to OrientDB
Hi.
I'm pretty sure that what i want to do is not possible but maybe someone has a workaround (or it may give ideas to implement in future versions).
Imagine you have a class Student with their average mark, and a class Mark. Every student a multiple marks.
What I would like to do is get the three best students with their marks.
I thought of something like: SELECT FROM (MATCH {class: Student, as: s}-has->{class: Mark, as: m}) ORDER BY s.avg_mark LIMIT 3
But of course it only returns 3 results (so for example if all students has 10 marks, i would only get that first student with 3 marks instead of 3 students with 10 marks each).
Any idea ?

Luigi Dell'Aquila

unread,
Apr 13, 2017, 8:57:34 AM4/13/17
to orient-...@googlegroups.com
Hi Nicolas,

You can try the following query:

SELECT @rid as student, out("has") as mark from (
   SELECT FROM Student ORDER BY avg_mark DESC LIMIT 3
) UNWIND mark

Thanks


Luigi


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nicolas treiber

unread,
Apr 13, 2017, 9:55:57 AM4/13/17
to OrientDB
Is there no way to use use the MATCH command ? the thing is that i can end up with very complex queries (with multiple relations, with different depth) which can fast become unreadble with select
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages