Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-04-2021 09:23 PM
Here's my query and below that is returned data
MATCH (n:citations)-[:WROTE_BY]->(a:authors) with n,a,count(a.name) as c where a.name IS NOT NULL RETURN a.name,n.year order by a.name;
| "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.
Solved! Go to Solution.
01-05-2021 01:33 AM
Hello,
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
ORDER BY p.name
Cheers !
Marius
01-05-2021 01:33 AM
Hello,
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
ORDER BY p.name
Cheers !
Marius
01-05-2021 09:27 AM
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 a.name, max-min+1 as yearsActive
ORDER BY yearsActive
All the sessions of the conference are now available online