neo4j 密码嵌套查询

bweufnob  于 11个月前  发布在  其他
关注(0)|答案(2)|浏览(159)

试图在cypher sql中构建嵌套查询来查找grossale,distinctcustomer和salesreach的销售额,并且无法将列1的值作为输入传递给另一列-任何帮助都将不胜感激。
在这里

MATCH (n:Commercial)
WITH (n) AS grosssales, count(n) AS distinctcustomer, 
  n.customer_id AS customer, ### grouping by customer_id ###
  grosssale / distinctcustomer AS salesreach
RETURN grossale, distinctcustomer, salesreach, customer_id

字符串
尝试了WITH子句,但没有喜悦,将感谢任何帮助,在纠正密码语法。

vof42yt1

vof42yt11#

MATCH (n:Commercial) 
WITH count(n) AS grosssales 
MATCH (c:Commercial) 
WITH grosssales,count(c) AS distinctcustomer, c.customer_id AS customer, tofloat(grosssales/count(c)) AS salesreach 
RETURN imp AS grosssales, distinctcustomer, customer, salesreach

字符串

nr9pn0ug

nr9pn0ug2#

可以使用新的COUNT subquery(neo4j 5.0+中)来计算Commercial节点的总数,从而简化查询。尽管COUNT()是一个聚合函数,但customer子查询不是--因此它不受customer分组键的影响。

MATCH (c:Commercial) 
WITH COUNT{ (:Commercial) } AS grosssales, COUNT(c) AS distinctcustomer, c.customer_id AS customer
RETURN grosssales, distinctcustomer, customer, TOFLOAT(grosssales/distinctcustomer) AS salesreach

字符串

相关问题