Reputation: 55
I recently started with neo4j. I am having trouble with COUNT()
function.
My nodes have a label say 'consumers' and All consumers nodes have a property called 'status' which can have two values 'active' or 'inactive.'
I want to count call consumer nodes as well as all nodes where consumers.status = "active"
in a single query.
I have tried match (n:Consumers) return count(n), count(n) where consumer.status="active"
I have tried to use 'where' clause in different places like before return and count with condition using 'as' but it doesn't work. what am I doing wrong?
Upvotes: 1
Views: 49
Reputation: 6534
Try the following:
match (n:Consumers)
return count(n), sum(CASE WHEN consumer.status="active" THEN 1 ELSE 0 END) as active
Upvotes: 1