cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to show only most recent relationship

bill1
Node Link

How do you run a MATCH and RETURN query to show the only the most recent relationship between nodes by date? Relationship properties include username, date, and there can be dozens of relationships between nodes and nodes have chained relationships (A->B->C->...->Z).

1 REPLY 1

daveb
Node Link

Without really knowing much about your setup, simplistically, based on what you ahve described, you can find the most recent relationship this way

// match all relationships
MATCH ()-[rel:RELATIONSHIP]-()
RETURN rel.date AS date

// order them in descening order
ORDER by date DESC
LIMIT 1

This is a terrible query though. It requires more context to make it better.