I am using Neo4j and wondering how to use Cypher to loop through properties of other nodes connecting one node for comparison and filter the ones satisfy condition.
Here is the sample data:
Person Movie Publish_Date
Tina A 2016-01-01
Tina B 2016-01-01
Tina C 2016-03-05
Tina D 2016-03-06
Tina X 2018-03-09
Bob E 2016-08-01
Bob F 2016-08-08
Ana G 2016-04-05
Ana H 2016-08-05
Ana I 2016-12-05
Here is what I want:
Person Movie Publish_Date
Tina A 2016-01-01
Tina B 2016-01-01
Tina C 2016-03-05
Tina D 2016-03-06
Tina X 2018-03-09
Bob E 2016-08-01
Bob F 2016-08-08
I want to return the person who participated in more than 2 movies published in 30 days and movie information.
What I thought to do is for each Person, loop through the publish date of movie nodes connecting with him and retain the ones satisfy the condition in the result table.
Here is my query for getting the sample data:
MATCH (p:Person)-[r1:ACTED_IN]->(m:Movie)
WITH p, m
ORDER BY p.Name DESC, n.Publish_Date
RETURN p.name AS Person, m.title AS Movie, m.publish_date AS Publish_Date
Please suggest.
Thanks in advance!
Tina X 2018-03-09
should not be returned, as it was published several years after the previous movie on2016-03-06
– InverseFalconin more than 2 movies published in 30 days
. Do you mean "at least 2 movies published in 30 days"? – InverseFalcon