2013-08-07 40 views
0

我可以把條件放在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

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)) 
+0

感謝@斯蒂芬 - ARMBRUSTER,應關係的性質這項工作?我已經在這裏上傳了示例數據:http://stackoverflow.com/questions/17947903/search-list-with-mutual-count-2nd-try?noredirect=1#comment26542030_17947903 –

+0

是的,過濾器處理關係屬性,請參閱更新以上。 –

+0

您好@ stefan-armbruster,我已檢查您的查詢。它工作正常,但沒有返回我的預期結果。我還想讓node6(名稱:dhansukh)的相互計數爲0或爲空。請在預期結果看看http://stackoverflow.com/questions/17947903/search-list-with-mutual-count-2nd-try?noredirect=1#comment26542030_17947903 –