在Neo4j中,如何在Cypher查询语言中使用类似SQL的GROUP BY?
我想找出一家公司所有用户的数量,以及该公司男女用户的数量。我的问题是:在Neo4j中,如何在Cypher查询语言中使用类似SQL的GROUP BY?,neo4j,cypher,Neo4j,Cypher,我想找出一家公司所有用户的数量,以及该公司男女用户的数量。我的问题是: start n=node:company(name:"comp") match n<-[:Members_In]-x, n<-[:Members_In]-y where x.Sex='Male' and y.Sex='Female' return n.name as companyName, count(distinct x) as NumOfMale, count(distinct y) as
start n=node:company(name:"comp")
match n<-[:Members_In]-x, n<-[:Members_In]-y
where x.Sex='Male' and y.Sex='Female'
return n.name as companyName, count(distinct x) as NumOfMale,
count(distinct y) as NumOfFemale" );
start n=节点:公司(名称:“comp”)
匹配n尝试
start n=node:node\u auto\u index(name='comp')
匹配n尝试
start n=node:node\u auto\u index(name='comp')
匹配nPeter在此处创建了一个叉积:
我认为这更适合您的用例
start n=node:node_auto_index(name='comp')
match n<-[:Members_In]-x
with n.name as companyName, collect(x) as employees
return length(filter(x in employees : x.Sex='Male')) as NumOfMale,
length(filter(x in employees : x.Sex='Female')) as NumOfFemale,
length(employees) as Total
start n=node:node\u auto\u index(name='comp')
匹配nPeter在此处创建了一个叉积:
我认为这更适合您的用例
start n=node:node_auto_index(name='comp')
match n<-[:Members_In]-x
with n.name as companyName, collect(x) as employees
return length(filter(x in employees : x.Sex='Male')) as NumOfMale,
length(filter(x in employees : x.Sex='Female')) as NumOfFemale,
length(employees) as Total
start n=node:node\u auto\u index(name='comp')
匹配n实际上有一种更简单的方法来实现这个结果
START n=node:node_auto_index(name='comp')
MATCH n<-[:Members_In]-x
RETURN count(x.name), x.Sex
START n=node:node\u auto\u index(name='comp')
匹配n实际上有一种更简单的方法来实现这个结果
START n=node:node_auto_index(name='comp')
MATCH n<-[:Members_In]-x
RETURN count(x.name), x.Sex
START n=node:node\u auto\u index(name='comp')
匹配