计数功能中的条件

时间:2013-08-07 12:29:03

标签: neo4j cypher

我可以将条件放入count()吗?让我解释一下。

START me=node:node_auto_index(UserProfileID = '1'), other=node(*) 
MATCH pMutualFriends=me-[r?:friends]-mf-[r1:friends]-other 
WHERE other.UserName? =~ '(?i)dh.*' AND other.UserProfileID? <> 1 
RETURN me.EMailID, other.EMailID,other.UserProfileID, other.UserName, r.ApprovalStatus,    COUNT(pMutualFriends) AS mutualCount

在上面的查询中我可以像这样使用。

COUNT(pMutualFriends where r.ApprovalStatus = 1 AND r1.ApprovalStatus =1 )

或者可能以其他方式?

由于

1 个答案:

答案 0 :(得分:1)

filter function应该对你有所帮助。如果您需要进一步的帮助,请在http://console.neo4j.org上提供数据样本并在此处分享。

举个例子:

START me=node:node_auto_index(UserProfileID = '1'), other=node(*) 
MATCH pMutualFriends=me-[r?:friends]-mf-[r1:friends]-other 
WHERE other.UserName? =~ '(?i)dh.*' AND other.UserProfileID? <> 1 
RETURN me.EMailID, other.EMailID,other.UserProfileID, other.UserName, 
  count(filter(x IN r.ApprovalStatus: x=1)), 
  count(filter(x IN r1.ApprovalStatus: x=1))
相关问题