Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-12-2020 12:26 AM
I am trying to count the number of elements in a list
UNWIND [{id:'0001',name:'Test',size:'10mm'}] as rows
RETURN count(rows)
However this always returns 1. For this example the return value should be 3, even if the list is empty then it should return 0.
Solved! Go to Solution.
06-12-2020 12:52 AM
Your datastructure is a 1-element array containing a map with 3 elements.
This returns 3:
unwind [{id:'0001',name:'Test',size:'10mm'}] as map
return size(keys(map))
You cannot apply size
on a map, therefore use keys()
to get an array of keys from the map.
06-12-2020 12:52 AM
Your datastructure is a 1-element array containing a map with 3 elements.
This returns 3:
unwind [{id:'0001',name:'Test',size:'10mm'}] as map
return size(keys(map))
You cannot apply size
on a map, therefore use keys()
to get an array of keys from the map.
06-12-2020 01:12 AM
Thanks for the help stefen.armbruster
All the sessions of the conference are now available online