Search code examples
neo4jcypher

count nodes per property neo4j database


I have nodes, called Book. Each node have property Name (owner's name). It's not a lot of names, a lot of books. How to run aggregate query of all Names, and book quantity per Name?

Name Book_Count
Sam  55
John 12

Database version: 3.5


Solution

  • [UPDATED]

    This will return the number nodes for each name:

    MATCH (b:Book)
    RETURN b.Name AS name, COUNT(*) AS book_count