变量未在 WITH 子句中定义
Variable not defined in WITH clause
在下面的查询中
MATCH (i:UT)-[c:Cedes]->(r:UT)
WHERE i.RiIndex=0
WITH r, c, i, (CASE WHEN i.gross > c.xs THEN i.gross-c.xs ELSE 0 END) AS mn
RETURN r, sum(c.pp*(mn)) AS ceded
执行得很好但是
MATCH (i:UT)-[c:Cedes]->(r:UT)
WHERE i.RiIndex=0
WITH r, c, i, (CASE WHEN i.gross > c.xs THEN i.gross-c.xs ELSE 0 END) AS mn, (CASE WHEN c.lim < mn THEN c.lim ELSE mn END) AS mx
RETURN r, sum(c.pp*(mx)) AS ceded
报如下错误
Variable `mn` not defined (line 3, column 97 (offset: 146))
"WITH r, c, i, (CASE WHEN i.gross > c.xs THEN i.gross-c.xs ELSE 0 END) AS mn, (CASE WHEN c.lim < mn THEN c.lim ELSE mn END) AS mx"
^
有人可以建议是否有办法将 'mn' 变量传递给创建 'mx' 变量的函数吗?
在您的 WITH 子句中,mn
在 WITH 子句完成之前不在范围内。之后你需要另一个 WITH 将它包含在范围内:
MATCH (i:UT)-[c:Cedes]->(r:UT)
WHERE i.RiIndex=0
WITH r, c, i, (CASE WHEN i.gross > c.xs THEN i.gross-c.xs ELSE 0 END) AS mn
WITH r, c, i, (CASE WHEN c.lim < mn THEN c.lim ELSE mn END) AS mx
RETURN r, sum(c.pp*(mx)) AS ceded
在下面的查询中
MATCH (i:UT)-[c:Cedes]->(r:UT)
WHERE i.RiIndex=0
WITH r, c, i, (CASE WHEN i.gross > c.xs THEN i.gross-c.xs ELSE 0 END) AS mn
RETURN r, sum(c.pp*(mn)) AS ceded
执行得很好但是
MATCH (i:UT)-[c:Cedes]->(r:UT)
WHERE i.RiIndex=0
WITH r, c, i, (CASE WHEN i.gross > c.xs THEN i.gross-c.xs ELSE 0 END) AS mn, (CASE WHEN c.lim < mn THEN c.lim ELSE mn END) AS mx
RETURN r, sum(c.pp*(mx)) AS ceded
报如下错误
Variable `mn` not defined (line 3, column 97 (offset: 146))
"WITH r, c, i, (CASE WHEN i.gross > c.xs THEN i.gross-c.xs ELSE 0 END) AS mn, (CASE WHEN c.lim < mn THEN c.lim ELSE mn END) AS mx"
^
有人可以建议是否有办法将 'mn' 变量传递给创建 'mx' 变量的函数吗?
在您的 WITH 子句中,mn
在 WITH 子句完成之前不在范围内。之后你需要另一个 WITH 将它包含在范围内:
MATCH (i:UT)-[c:Cedes]->(r:UT)
WHERE i.RiIndex=0
WITH r, c, i, (CASE WHEN i.gross > c.xs THEN i.gross-c.xs ELSE 0 END) AS mn
WITH r, c, i, (CASE WHEN c.lim < mn THEN c.lim ELSE mn END) AS mx
RETURN r, sum(c.pp*(mx)) AS ceded