Badmiral
Badmiral

Reputation: 1589

Can't use aggregate functions in the WHERE clause

Running this query in cypher

MATCH (v:Person)<--(a:Place)<--(s:Thing) WHERE count(s)>0 RETURN v

Getting this Error Message:

Can't use aggregate functions in the WHERE clause.

Obviously it doesn't like filtering on the count aggregate function. What is a good work around for this? Thanks!

Upvotes: 0

Views: 638

Answers (1)

Eve Freeman
Eve Freeman

Reputation: 33145

You guys almost had it in the comments.

MATCH (v:Person)<--(a:Place)<--(s:Thing) 
RETURN count(s) as count, v

If this is what is returning 1 counts for everything, are you sure you have more than one thing per person? You don't need to check that the count is > 0, because that is implied.

Upvotes: 2

Related Questions