I have the following query:
START e1=node:event(prop="0")
MATCH e1-[r:rbel]->e2
WITH e1, e2, count(e1) as ecount
MATCH e1-[:redge]->p<-[:redge]-e2
WITH p.element_type as Type, p.label as Label, (count(p)*100./ecount) as percentage
WHERE percentage > 20
RETURN Type, Label, ROUND(percentage) as Percentage
I am trying to calculate the percentage of times the specified pattern occurs in events with prop="0"
, over all patterns occurring in those events.
I receive the following error: Unknown identifier 'ecount'
So I replaced ecount
in the calculation with count(ecount)
, and that consistently yielded percentage
s of 100%, which I know not to be true.
Am I going about this wrong? How can I carry the value of ecount
to the WITH
clause and use it in calculation?
Any help is appreciated!
Does this query work for you? Whenever I combine
e1
andcount(e1)
in aWITH
statement, thecount(e1)
is always 1. I think that is because thecount(e1)
aggregation does not work any more when you selecte1
, too. Either you leave out thee1
or thecount(e1)
.UPDATE After playing around with your provided console setup I got the following query working: