我试图运行一个查询,我根据它们在查询中出现的顺序来指定整数。我希望它能够发挥作用:
MATCH users RETURN users ORDER BY created_at SET user.number=ROW_NUMBER()
有没有办法在单个查询中执行此操作?谢谢!
答案 0 :(得分:5)
你可以通过玩一个集合来做到这一点:
MATCH (n:User)
WITH n
ORDER BY n.created_at
WITH collect(n) as users
UNWIND range(0, size(users)-1) as pos
SET (users[pos]).number = pos