Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-17-2018 12:25 AM
I have nodes with one of the properties called "Model".
If I have node names as a,b,c,d,e etc,
a.Model="1"
b.Model="2"
c.Model="3"
d.Model="1" etc
I want to ask a query : "For a particular Model, return the count of relationships for each individual nodes "
If i ask for Model=1 , it should give me the count of relationships for each distinct node under Model 1.
need results like below
for Model="1"
a---> count of relationships for a
d---> count of relationships for d
Solved! Go to Solution.
09-17-2018 02:14 AM
Hi,
You can try this query :
MATCH (n:MyNodeLabel)
WHERE n.Model = "1"
RETURN n, size((n)-->()) AS count
NB : In this example, you should replace MyNodeLabel
by the label of your nodes.
Cheers.
09-17-2018 02:14 AM
Hi,
You can try this query :
MATCH (n:MyNodeLabel)
WHERE n.Model = "1"
RETURN n, size((n)-->()) AS count
NB : In this example, you should replace MyNodeLabel
by the label of your nodes.
Cheers.
11-28-2022 07:24 AM
what if I don't know that the value is "1" or "2" etc
and I want that it will recognize by itself and count it?
11-28-2022 10:03 AM
If you don’t want to filter by the value, you can leave out the where clause in get a count for all nodes.
if this is not what you meant, can you please describe what you are trying to accomplish?
11-28-2022 11:47 PM
I will try again-
I have a connection of multiple nodes and one of their properties is name, for the entire connections I want to count the appearance of each name, whatever it is.
11-29-2022 05:06 AM
Can you provide your data model? Do you want the total count of the number of nodes for each value of name, or is the restricted to the related nodes of a node?
11-29-2022 05:18 AM
I can't give the data..
the second option- restricted to the related nodes of a node
11-29-2022 06:28 AM
This is very generic since I don't have a data model. It shows how to count the number of related nodes by the name property for each node in your database. You will need to tailor it to your data model.
match(n)--(m)
return n, m.name, count(*) as cnt
Is this what you are looking for?
11-28-2022 11:36 AM
When you say "Node name" as a, b, c, etc. - what do you mean? Is there a property called "name" on the nodes?
All the sessions of the conference are now available online