Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-24-2023 07:54 AM
Hello Everyone,
I really need your help with a cypher code. I am working on a project and I a have the schema below.
I want for every element in the "Network_Name" column and for each Datetime (distinct selection according to the Network_Name and Datetime) to count the number of user and return those three columns ("Network_Name", "Datetime" and user count).
Any help please
I hope I was clear enough
Thank in advance
Solved! Go to Solution.
01-24-2023 09:13 AM
Assuming a data model as follows:
Then, the following query should work:
match(n:Network)<-[:BELONGS_TO]-(u:User)
return n.network_name as network_name, n.datetime as datetime, count(u) as user_count
The key point is in the 'with' statement, where the statement groups the rows by 'network_name' and 'datatime' of the network node, then counts the number of users for each distinct group. This is how the aggregation functions works, i.e., the rows are grouped by the distinct values of the variables provided on the 'with' or 'return' statement, whenever an aggregate functions exists.
01-24-2023 09:03 AM
You forgot to provide the schema/data model.
01-24-2023 09:13 AM
Assuming a data model as follows:
Then, the following query should work:
match(n:Network)<-[:BELONGS_TO]-(u:User)
return n.network_name as network_name, n.datetime as datetime, count(u) as user_count
The key point is in the 'with' statement, where the statement groups the rows by 'network_name' and 'datatime' of the network node, then counts the number of users for each distinct group. This is how the aggregation functions works, i.e., the rows are grouped by the distinct values of the variables provided on the 'with' or 'return' statement, whenever an aggregate functions exists.
01-24-2023 09:42 AM
Hello glilienfield
Sorry I forget the schema but you guess it right.
That work perfectly.
Thank you very much
All the sessions of the conference are now available online