我有成功運行一個查詢所有節點:Neo4j的查詢 - 查找其滿足資產狀況和有關係
match (n:A {tag_no:"N2203"})<-[:rel_a]-(v:B)-[:rel_b]->(r)<-[:rel_c]-(n) WHERE (v.invoice_date>="2012-08-01" AND v.invoice_date<"2016-02-01") with v, collect(r) as rs where all (x in rs where x.date<"2016-08-01") return count(v) as count;
我需要進一步過濾此查詢。
我需要相關r nodes with max(r.date) for each v
,並找出有多少節點有型D
我想這個查詢的其他節點的關係,它拋出一個語法錯誤
match (n:A {tag_no:"N2203"})<-[:rel_a]-(v:B)-[:rel_b]->(r)<-[:rel_c]-(n) WHERE (v.invoice_date>="2012-08-01" AND v.invoice_date<"2016-02-01") with v, max(r.date) as date collect(r) as rs where (all (x in rs where x.date<"2016-08-01") AND filter(x in rs where x.date=date)[0]<-[:rel_c]-(d:D)) return count(v) as count;
我也試過很多其他的組合,但都拋出一些語法錯誤。所有的幫助表示讚賞。
你的查詢將受益於格式化,這將使debuggind容易。請使用4個縮進空格(而不是三重反引號),並在查詢中使用更多的空格。我在https://gist.github.com/szarnyasg/8b53983b5ade8a31e4410f8f48ee3653創建並示例 –