Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Return count() from Cypher pattern comprehension

Is it possible to return count() from Cypher pattern comprehension ?

The following query doesn’t work:

[ (:Vacancy)<-[rpp:POTENTIAL_PROFILE]-(childD) | count(rpp) ] AS potentialJobablesCount

with the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Aggregation column contains implicit grouping expressions. For example, in 'RETURN n.a, n.a + n.b + count(*)' the aggregation expression 'n.a + n.b + count(*)' includes the implicit grouping key 'n.b'. It may be possible to rewrite the query by extracting these grouping/aggregation expressions into a preceding WITH clause. Illegal expression(s): rpp

>Solution :

Aggregation functions like COUNT can only be used in WITH and RETURN clauses.

But starting with neo4j 5.0 you can use the new COUNT subquery. For example:

MATCH (childD:ChildD {id:123})
RETURN COUNT { (:Vacancy)<-[:POTENTIAL_PROFILE]-(childD) } AS potentialJobablesCount
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading