How to calculate and display author with most number of years publication

Here's my query and below that is returned data

MATCH (n:citations)-[:WROTE_BY]->(a:authors) with n,a,count( as c where IS NOT NULL RETURN,n.year order by;

| "Victor Mitrana" | 1993 |
| "Victor Mitrana" | 1996 |
| "Victor Mitrana" | 1998

I need to calculate 1998-1993 , bascially max(year) - min ( year ) for each author and display author and longest publication year for each author. Not sure how to achieve it.


This query does the trick (note : I tried on the movie database, just replace Person and Movie by Author and citation as you need)

MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WITH p, max(m.released) as max, min(m.released) as min
RETURN p, max-min+1 as yearsActive

Cheers !



Thank you so much that trick certainly worked. Now I can see author with longest career.

MATCH (p:citations)-[:WROTE_BY]->(a:authors)
WITH a, max(p.year) as max, min(p.year) as min
RETURN, max-min+1 as yearsActive
ORDER BY yearsActive

1 Like