cypher - 如何在 AgnsGraph 中修改以下密码语法?
问题描述
MATCH (wu:wiki_user) 可选匹配 (n:wiki_doc{author:wu.uid}), (o:wiki_doc{editor:wu.uid}) RETURN wu.uid AS User_id, wu.org AS Organization, wu.email AS email, wu.token AS balance, count(n) AS Writing, count(o) AS Modifying;
user_id | organization | email | balance | writing | modifying
--------------------------------------------------------------------------
"ailee" | "Org2" | "hazel@gbc.com" | 5 | 0 | 0
"hazel" | "Org1" | "hazel@gbc.com" | 5 | 2 | 2
match (n:wiki_doc{editor:'hazel'}) return n;
n
wiki_doc[9.11]
{"bid": "hazel_doc1", "cid": "Basic", "org": "Org1", "title": "Hello world!",
"author": "hazel", "editor": "hazel", "revnum": 1, "created": "2018-09-25
09:00:000", "hasfile": 2, "contents": "I was wrong", "modified": "2018-09-25
10:00:000"}
(1 行)
实际上,在hazel的情况下更新次数是1,使用上面的查询时使用了2次查询。
如何修改查询,使只能正常查看一个。
解决方案
MATCH(
wu:wiki_user
)
OPTIONAL MATCH(n:wiki_doc{author:wu.uid})
,(o:wiki_doc{editor:wu.uid})
RETURN wu.uid AS User_id, wu.org AS Organization, wu.email AS email, wu.token AS balance,
count(distinct id(n)) as Writing, count(distinct id(o))
as Modifying;
user_id | organization | email | balance | writing | modifying
+----------------------------------------------------------+
"ailee" | "Org2" | "hazel@gbc.com" | 5 | 0 | 0
"hazel" | "Org1" | "hazel@gbc.com" | 5 | 2 | 1
(2 行)
推荐阅读
- android - 回收站视图再次绑定项目时下载进度消失
- javascript - 被动事件监听器、fullpage.js、回调
- lua - 尝试为对象索引字段(零值)
- laravel - Laravel 5.6 通配符路由在域中未按预期运行
- android - 在 AlertDialog 的 setPositiveButton OnClickListener() 中编写逻辑
- visual-studio-code - 如何在 VSCode 的笔记本编辑器中打开 .py 文件
- html - 显示: flex - 两个元素水平成 500px
- ruby - Watir,通过自定义属性定位元素
- functional-programming - Curry-Howard 的同构可以在哪些编程语言上实现?
- amazon-web-services - Kafka Follower Fetch 很高