Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-05-2020 05:08 PM
@michael.hunger
I have 4 person nodes belong to same team where team name is a property in node, one person has a relation to a new node community as the score is > 100, as shown
CREATE (Paul:Person {id:'1', name:'Paul', Team:'T1', Joined:datetime('2020-03-04T23:13:49.990000000Z'), Score: 111})
CREATE (Jean:Person {id:'2', name:'Jean', Team:'T1', Joined:datetime('2020-03-03T23:13:49.990000000Z'), Score: 88})
CREATE (Dan:Person {id:'3', name:'Dan', Team:'T1', Joined:datetime('2020-03-02T23:13:49.990000000Z'), Score: 45})
CREATE (Mike:Person {id:'4', name:'Mike', Team:'T1', Joined:datetime('2020-03-01T23:13:49.990000000Z'), Score: 36})
CREATE (Community:Teams {id:'11', name:'Community', street:'2626 Wilkinson Court', address:'San Bernardino, CA 92410'})
CREATE (Paul)-[:SCORE_AB100]->(Community)
RETURN *
Each person node has a property named Score, i want to create a new relation between nodes Jean,Dan who joined in last two days to the node Community, if the sum of Scores of 3 nodes(Paul,Jean,Dan) is greater than 200.
To return these nodes
MATCH (p:Person{Team: 'T1'})
WHERE datetime(p.Joined) > datetime('2020-03-01T23:14:49.990000000Z')
MATCH (p1:Person{Team: 'T1'})-[r:SCORE_AB100]-(t:Teams)
RETURN p,r,t,p1
To return the score and sum
MATCH (p:Person{Team: 'T1'})
WHERE datetime(p.Joined) > datetime('2020-03-01T23:14:49.990000000Z')
MATCH (p1:Person{Team: 'T1'})-[r:SCORE_AB100]-(t:Teams)
RETURN collect(p.Score),sum(p.Score)
As the sum is above 200, i want to create a new relation [:SCORE_AB200] between Jean to Community and Dan to Community, and also paul to community another relation.
I tried using sum(p.Score) > 200 in WHERE its showing error
Solved! Go to Solution.
03-05-2020 08:14 PM
03-05-2020 05:41 PM
i tried something like this
MATCH (p:Person),(t:Teams)
WHERE datetime(p.Joined) > datetime('2020-03-01T23:14:49.990000000Z')
WITH sum(p.Score) as total, collect (id(p)) as per
MATCH (p1:Person) WHERE id(p1) in per AND total > 200
CREATE (p1)-[r:SCORE_AB200]->(t:Teams)
RETURN per,total
but not working
03-05-2020 08:14 PM
All the sessions of the conference are now available online