我正在尝试执行以下 Cypher 查询
START b=node:customer_idx(ID = 'ABCD')
MATCH p = b-[r1:LIKES]->stuff, someone_else_too-[r2:LIKES]->stuff
with b,someone_else_too, count(*) as matchingstuffcount
where matchingstuffcount > 1
//with b, someone_else_too, matchingstuffcount, CASE WHEN ...that has r1, r2... END as SortIndex
return someone_else_too, SortIndex
order by SortIndex
上面的查询工作正常,但是当我取消注释较低的“with”时,我得到了以下错误
Unknown identifier `b`.
Unknown identifier `someone_else_too`.
Unknown identifier `matchingstuffcount`.
Unknown identifier `r1`.
Unknown identifier `r2`.
为了解决这个问题,我在顶部包含 r1 和 r2 以及 - "with b,someone_else_too, count(*) as matchingstuffcount".
to"with b, r1, r2, someone_else_too, count(*) as matchingstuffcount".
这会弄乱我的count(*) > 1
条件,因为 count(*) 没有正确聚合。
在确保 Case When 也可以执行的同时过滤掉 count(*) > 1 的任何解决方法/建议?