Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-21-2022 04:21 AM
Hi I am having syntax error while converting these into cypher queries.How can I work with this please
Query:
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;
Solved! Go to Solution.
11-21-2022 08:49 AM
What is your domain model, so I can write an equivalent cypher for your sql query? I will assume the following model to give you an illustration of the equivalent cypher query.
The following query will give you a list of manager's with orders and their order count:
match(m:Manager)-[:HAS_ORDER]->(o:Order)
return m.name, count(o) as numOfOrders
11-21-2022 08:49 AM
What is your domain model, so I can write an equivalent cypher for your sql query? I will assume the following model to give you an illustration of the equivalent cypher query.
The following query will give you a list of manager's with orders and their order count:
match(m:Manager)-[:HAS_ORDER]->(o:Order)
return m.name, count(o) as numOfOrders
11-21-2022 06:49 PM
Hi thank you so much .It works for me. Can you please help me with this last two queries. Highly appreciated.I have added the cypher query I tried at last.I am having syntax error.Please if you dont mind.I just started with Neo4j
Manager wants to know about details of all the customers and their orders whose order status is delivered and order value is between 900 USD and 1300 USD.
Query 1:
SELECT *
FROM sOrder
INNER JOIN
Customer ON sOrder.Cust_id = Customer.Cust_id
WHERE sOrder.status = 'Delivered' AND
Order_id IN (
SELECT Order_id
FROM sOrder
WHERE order_value BETWEEN 900 AND 1300
);
The manager wants to name of all the customer who have placed order of more than 5 items.
Query 2:
SELECT cust_name
FROM sOrder
INNER JOIN
Customer ON sOrder.Cust_id = Customer.Cust_id
WHERE Order_id IN (
SELECT Order_id
FROM sOrder
WHERE no_of_items > 5
);
Query I tried:
Query 1
cypher//query_5
MATCH (o:Order {o.status:"Delivered"} ) )<-[c:Customer] AND o:order_id IN (Match (i) where i.order_value range (900 , 1300) return i.order_id)
RETURN o;
Query 2:
MATCH (o:Order {o.status:"Delivered"} ) )<-[c:Customer] AND o:order_id IN (Match (i:Order) where i.no_of_items > 5 return i.order_id)
RETURN o.cust_namer;
11-21-2022 07:02 PM
Yes, I am happy to help. Are you already using neo4j? If so, do you have a data model you can share with me so I can help with the exact queries?
your queries do not use correct cypher syntax. You are mixing sql and some cypher. I will rewrite them tomorrow, but having your data model would be better than me making one up.
11-21-2022 07:25 PM - edited 11-21-2022 07:26 PM
Thank you for replying. I have added graph model as per what in Neo4j it looks like.Actually I do have CSV files imported from sqlite.
11-22-2022 02:41 AM
11-22-2022 05:07 PM
Hi please help if you’re available.I have a project due today and stucked with these queries.Thanks again
11-22-2022 08:19 PM
Query 1:
MATCH (o:orders)
WHERE o.Status = "Delivered" and 900 <= o.order_value <= 1300
MATCH (o)-[:PROCESSES_TO]->(c:customer)
RETURN c, o
Query 2:
MATCH (o:orders)-[:PROCESSES_TO]->(c:customer)
WITH c, count(o) as orderCount
WHERE orderCount > 5
RETURN c.Cust_id, c.Cust_name, orderCount
Let me know how they work.
11-23-2022 05:57 AM
Thank you so much for your help…for now it worked for me.I will go through the course for better understanding.Thanks again!
11-23-2022 05:15 AM
You should take free courses neo4j offers. The beginner level ones will really help you get started. I also read the cypher manual over and over until I really grasped the language.
All the sessions of the conference are now available online