cancel
Showing results for 
Search instead for 
Did you mean: 

Aggregation

kool_hetal
Node

In the 'Working with Cypher'-> Check your understanding , first question around aggregate functions, why is size() not considered an aggregate function if count is?

2 REPLIES 2

poornima
Node Clone

Hi,

size() takes in an aggregate data structure such as a list of values as input whereas the use of an aggregating function like count() requires a grouping of rows i.e. aggregation by some criteria is required to produce an output. From the perspective of the query processor, size() doesn't trigger off an aggregation operation where as count() does.

The result of using count() is a first obtaining a set of rows conforming to some criteria and then calculating the size of that set. The result of using size() is simply counting the number of values in a list that already exists.

Hope this makes it clear.

This is the size() function listed under scalar functions -

This is the count() function listed under aggregating functions -

ameyasoft
Graph Maven
A person has about 100 (count) friends. Out of this 100 the person like only 25. Then  in Cypher you collect the total  number of friends by using count(friends). This is aggregate. 


Out of that 100 friends,  the person likes only 25. You can collect all the friends liked
The result shows a collection of the friends like ["F1", "F2", "F3"]. Then you the size function to get the count of liked friends

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.