【问题标题】:Neo4j and cypher queries confusionNeo4j 和 cypher 查询混淆
【发布时间】:2022-11-26 06:27:10
【问题描述】:

需要一些想法将 SQL 查询转换为密码查询。组织的所有者想知道每个经理接受了多少订单。

询问:

SELECT Manager_name,
Count(Order_id) AS number_of_orders
FROM Manager
INNER JOIN
sOrder ON Manager.Manager_id = sOrder.Manager_id
GROUP BY sOrder.Manager_id; 

【问题讨论】:

  • 请向我们展示您尝试过的查询。谢谢。
  • 这是我尝试过的 MATCH<-[:PRODUCT]-(:Order)<-[:PURCHASED]-(c:Customer)RETURN Manager_name。我是 Neo4j 的新手,所以这对我来说非常艰难

标签: neo4j


【解决方案1】:

不知道你所有的节点/关系类型是非常混乱的。猜测您有 3 种类型的节点;

  • 订单
  • 客户
  • 经理

有两种类型的关系;

  • 已购买
  • 有订单
// match all customers c that purchased an order o
MATCH (c:Customer) - [:Purchased] -> (o:Order)
WITH o
// match all the managers that are assigned to the order o
MATCH (m:Manager) - [:HasOrder] -> o
// return the name of the manager and the amount of the orders
return m.name as managerName, count(o)

了解我掌握的信息,这将是我的猜测。

NEO4J上有免费课程

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-01
    • 2017-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多