I'm trying to wrangle some data here. I've got a relationship set up that looks like:
(:Well {lastProdDate: Date})-[:ON]->(:Abstract {name: Name})
I'm trying to single out abstracts that have wells where 100% of the production is earlier than a certain date. So far I've got:
WITH DATE("2019-01-01") as endDate
MATCH (w:Well)-[:ON]->(a:Abstract)
With Collect(w.lastProdDate) as dates
After that I need to loop through the dates and return only abstracts where all dates are less than endDate. Any one done anything similar?
ameyasoft
( Ameyasoft)
January 19, 2020, 10:54pm
2
WITH DATE("2019-01-01") as endDate
MATCH (w:Well)-[:ON]->(a:Abstract)
WHERE w.lastProdDate <= endDate
With Collect(w.lastProdDate) as dates
Without WITH,
WHERE w.lastProdDate <= "2019-01-01"
1 Like
That's not quite it, it does indeed return a collection of the dates that match that criteria but it doesn't return only the collections where all pass. You've got me closer though, thank you!
MATCH (a:Abstract {name: Name})
WHERE ALL( w IN [(w)-[:ON]->(a) | w] WHERE w.lastProdDate > $date)
RETURN a
or
MATCH (a:Abstract {name: Name})
WHERE size( ()-[:ON]->(a)) = size[(w)-[:ON]->(a) WHERE w.lastProdDate > $date | w])
RETURN a
1 Like