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.
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?