Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-17-2022 03:19 AM
Hello Neos,
I have two different types of nodes: (:Customer) (with an id) and (:Invoice) (with a string_id which contains the year of the issuance of the invoice). Those two types of nodes are related via a [:INV_FOR_CUST].
I would like to find those customers for which no invoice containing the current year in the inv_string_id has been issued.
How could I create a query for those?
Best regards,
JJJ
04-17-2022 12:18 PM
Try this:
MATCH (a: Invoice) where a.string_id contains("2022")
and not (a)-[:INV_FOR_CUST]-(:Customer)
RETURN a
04-17-2022 02:14 PM
@ameyasoft approach is correct, but the solution mistakenly returns the invoice, not the customer as required. Rearranging @ameyasoft solution should give you the list of customers.
MATCH(c:Customer)
MATCH(i:Invoice WHERE i.string_id contains "2022")
WHERE not exists ( (i)-[:INV_FOR_CUST]->(c) )
RETURN c.id
04-19-2022 09:05 PM
Good Morning,
Thank you for your trials but I had tried them out before, but they are not working properly. So what I did is:
MATCH (c:Customer)<-[INV_FOR_CUST]-(inv:Invoice)
WHERE inv.inv_id_strg CONTAINS "2022"
WITH DISTINCT c.cust_id as cust_id
ORDER BY cust_id ASC
WITH collect(cust_id) as c_list
MATCH (c1:Customer)
WHERE NOT c1.cust_id IN c_list
MATCH (c1)-[:HAS_CUST_STATE]-(c1s)
WHERE NOT (c1s)<-[:HAS_CUST_STATE_PRED]-(:Customer_State) AND c1s.cust_status = 1 AND (c1s.cust_no_invoice = FALSE OR c1s.cust_no_invoice IS NULL)
RETURN c1, c1s
This now works.
Best regards,
JJJ
All the sessions of the conference are now available online