I'm currently trying to get the count of all movies that each actor has acted in (neo4j example movie database), and then set that as a `num_movies_acted` attribute for the person node.

So far, I'm able to get a list of all the actors and their respective movie count (including if it's 0 because of the OPTIONAL MATCH)

This is what I have:

```
MATCH (p:Person)
OPTIONAL MATCH (p)-[:ACTED_IN]->(m:Movie)
RETURN p.name as name, count(m) as num_movies_acted

```

How would I then set that into the Person Node? I know I should use something like:

`SET p.num_movies_acted = count(m)`, but that fails to work.

```
Invalid use of aggregating function count(...) in this context (line 3, column 26 (offset: 84))
"SET p.num_movies_acted = count(m)"

```

EDIT: Would this work?

```
MATCH (p:Person)
OPTIONAL MATCH (p)-[:ACTED_IN]->(m:Movie)
WITH p, count(m) as num_movies_acted
SET p.num_movies_acted = num_movies_acted
RETURN p

```

since I am "storing" the count(m) into a variable first