nboubakr
(Nboubakr)
June 3, 2022, 9:01pm
1
I am trying to select all nodes that have a relationship with a specific property but return only those with redundant property values. For example:
MATCH (:Node)-[a:Send{Flag: 'A'}]->(m:Node)
RETURN [m.Name, a.Port] AS output
It returns
["Device A", 22]
["Device A", 22]
["Device A", 22]
["Device A", 93]
["Device A", 93]
["Device A", 554]
["Device A", 445]
I want the output to be
["Device A", 22, 3]
["Device A", 93, 2]
cobra
(Cobra)
June 3, 2022, 9:25pm
2
Hello @nboubakr
MATCH (:Node)-[a:Send {Flag: 'A'}]->(m:Node)
WITH m.Name AS name, a.Port AS port, count(*) AS occurrences
WHERE occurrences > 1
RETURN [name, port, occurrences] AS output
Regards,
Cobra
ameyasoft
( Ameyasoft)
June 5, 2022, 3:30am
3
Try this:
WITH distinct a.port as Port, m.name as Name, count(distinct m.name) as NameCount
RETURN Name, Port, NameCount order by Name