Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-15-2020 05:05 PM
Hi everyone,
What's currently the best approach to returning all nodes of a specific type, plus some results of a subquery for each node?
Essentially I'm wanting to do something like:
MATCH (m:Movie)
CALL {
WITH m
MATCH (p:Person)-[role:ACTED_IN]->(m)
RETURN p, role
ORDER BY role.earnings DESC
LIMIT 1
}
RETURN p.name, role.earnings, m.title
However I believe this only looks like it's possible to do (I'm guessing) with fabric - it doesn't work in Neo4j browser.
Solved! Go to Solution.
06-16-2020 02:32 AM
Hi Louis,
I think it is much easier (if I correctly understand what you want):
MATCH (p:Person)-[role:ACTED_IN]->(m:Movie)
WITH max(role.earnings) AS maxRoleEarnings, m
MATCH (p:Person)-[role:ACTED_IN]->(m)
WHERE role.earnings = maxRoleEarnings
RETURN p.name, role.earnings, m.title
So this query gives you the highest paid actor per movie. Is that what you wanted?
Regards,
Elena
06-16-2020 02:32 AM
Hi Louis,
I think it is much easier (if I correctly understand what you want):
MATCH (p:Person)-[role:ACTED_IN]->(m:Movie)
WITH max(role.earnings) AS maxRoleEarnings, m
MATCH (p:Person)-[role:ACTED_IN]->(m)
WHERE role.earnings = maxRoleEarnings
RETURN p.name, role.earnings, m.title
So this query gives you the highest paid actor per movie. Is that what you wanted?
Regards,
Elena
06-16-2020 03:09 PM
Thanks Elena,
Yes that's what I was looking for! Appreciate your input.
Cheers,
Louis
All the sessions of the conference are now available online