我有很多产品,想知道有多少百分比有效,
我是Cypher的新手并试图使用WITH keyword
但没有成功:
MATCH (n:ratedItem)
WHERE n.idCategory = "45" AND
n.isValidate = "1" AND
n.value_fr = 1
WITH count(n) as totalValidate
MATCH (n:ratedItem)
WHERE n.idCategory = "45"
WITH count(n) as total
RETURN (totalValidate / total) * 100
我有语法错误,似乎Cypher不知道第一个计数totalValidate
感谢您的帮助
答案 0 :(得分:1)
你已经忘记了第二个WITH
:
MATCH (n:ratedItem)
WHERE n.idCategory = "45" AND
n.isValidate = "1" AND
n.value_fr = 1
WITH count(n) as totalValidate
MATCH (n:ratedItem)
WHERE n.idCategory = "45"
WITH count(n) as total, totalValidate
RETURN (totalValidate / total) * 100