2013-08-07 2 views
0

count()에 조건을 넣을 수 있습니까? 설명하겠습니다.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에 데이터 샘플을 제공하고 여기에서 공유하십시오. 예를 들어

: 스테판 - ARMBRUSTER @

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

덕분에, 관계의 재산에이 일을해야합니까? 샘플 데이터를 이미 업로드했습니다. http://stackoverflow.com/questions/17947903/search-list-with-mutual-count-2nd-try?noredirect=1#comment26542030_17947903 –

+0

예, 필터는 관계 속성에 적용됩니다 (업데이트 참조). 위. –

+0

안녕하세요. @ stefan-armbruster 님, 귀하의 질문을 확인했습니다. 그것은 잘 작동하지만 내 기대 결과를 반환하지 않았다. 나는 상호 수 0 또는 null 인 node6 (name : dhansukh)도 원한다. http://stackoverflow.com/questions/17947903/search-list-with-mutual-count-2nd-try?noredirect=1#comment26542030_17947903 –