I have a lot of nodes, containing the property gender
. Possible values for gender
are: male, female and andy. I am looking for a cypher query, that will return the count of each value. For example...
"male" 100
"female" 132
"andy" 12
The solution should also work for nodes with a property with more than three cases, eg. names, and the number of persons with the name.
This very simple query will return a count of every distinct gender
value. You can do the same thing for any property with any number of possible values.
MATCH (n)
RETURN n.gender, COUNT(*)
You should modify the MATCH
clause to specifically pick nodes that actually have the property you are counting. (Any matched nodes that do not have that property would also be counted, with a value of null
-- and appear in the results.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With