cypher 从结果中删除 null
cypher remove null s from result
我在 neo4j 中创建了一个查询:
MATCH (x:Node)-[r*1..2]->(y:Node)
WITH x AS x, SIZE(COLLECT(DISTINCT y)) AS y
WITH CASE
WHEN y=10 THEN x.target
END AS l
return l AS target
但是 returns 类似 :
target
____
null
null
"test1"
null
null
"tes56"
...
我想要的是:
target
____
"test1"
"tes56"
...
条目中没有空值。我怎样才能做到这一点?
您本应使用 WHERE,却使用了 CASE/WHEN(不会过滤掉行)。
此外,size(collect(DISTINCT ))
实际上只是一个 count(DISTINCT )
聚合,所以请改用它。
另外,为了避免混淆,可以为计数结果使用不同的变量名。
MATCH (x:Node)-[*1..2]->(y:Node)
WITH x, count(DISTINCT y) AS yCount
WHERE yCount = 10
RETURN x.target AS target
我在 neo4j 中创建了一个查询:
MATCH (x:Node)-[r*1..2]->(y:Node)
WITH x AS x, SIZE(COLLECT(DISTINCT y)) AS y
WITH CASE
WHEN y=10 THEN x.target
END AS l
return l AS target
但是 returns 类似 :
target
____
null
null
"test1"
null
null
"tes56"
...
我想要的是:
target
____
"test1"
"tes56"
...
条目中没有空值。我怎样才能做到这一点?
您本应使用 WHERE,却使用了 CASE/WHEN(不会过滤掉行)。
此外,size(collect(DISTINCT ))
实际上只是一个 count(DISTINCT )
聚合,所以请改用它。
另外,为了避免混淆,可以为计数结果使用不同的变量名。
MATCH (x:Node)-[*1..2]->(y:Node)
WITH x, count(DISTINCT y) AS yCount
WHERE yCount = 10
RETURN x.target AS target