 # Aggregation

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

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 -

``````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

``````