Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Neo4j中,如何在Cypher查询语言中使用类似SQL的GROUP BY?_Neo4j_Cypher - Fatal编程技术网

在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')
匹配