Clark L
Clark L

Reputation: 45

Cypher query to return counts of node groups

I have a graph with a large number of nodes that have a "category" as a property (or I could re-structure the data to have that category be a node label if that makes it easier). I am looking for a way to query the graph to return all the possible "categories" in the graph along with the counts of all the nodes for each.

Upvotes: 1

Views: 114

Answers (1)

Martin Preusse
Martin Preusse

Reputation: 9369

This should work:

MATCH (n)
WHERE has(n.category)
RETURN DISTINCT n.category, count(n)

Upvotes: 2

Related Questions