2
我想執行這個查詢暗號嵌套收集查詢不正確地聚集
MATCH (p:Person)-->(s:Startup)
WITH DISTINCT p
MATCH (p)-->(s:Startup)-->(m:Market)
WITH DISTINCT p, s, m, COLLECT(m) as markets
ORDER BY id(s)
RETURN DISTINCT p, COUNT(DISTINCT s) as inv,
COLLECT({id: id(s), markets: markets}) as startups,
count (m) as mctotal
ORDER BY inv DESC
LIMIT 10
,但我想不出爲什麼它不聚集與他們的市場正確創業公司。 這是我查詢的結果:
+-----+-----+------------+---------+
| p | inv | startups | mctotal |
+-----+-----+------------+---------+
| p | 11 | id: 1 | 7 |
| | | markets: 1 | |
| | | | |
| | | id: 1 | |
| | | markets: 2 | |
| | | | |
| | | id: 2 | |
| | | markets: 3 | |
| | | | |
| | | id: 2 | |
| | | markets: 4 | |
...等等。
,我想獲得的結果如下:
+-----+-----+---------------+---------+
| p | inv | startups | mctotal |
+-----+-----+---------------+---------+
| p | 11 | id: 1 | 7 |
| | | markets:[1,2] | |
| | | | |
| | | id: 2 | |
| | | markets:[3,4] | |
我希望這是清楚我所要求的。
不要使用不同的聚合它沒有意義 – 2014-10-11 22:38:26
謝謝,我知道,但與此查詢,如果我不使用DISTINCT它計數所有的結果和perfoms假計數 – 2014-10-12 09:09:32