Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-05-2020 08:03 AM
I am trying to extract the count of all accounts having conversation
Below is the query
match (PS:PrdSer)<-[:HAS_PS]- (PR:Product)-[H:HAS_PRODUCT]-(A:Account)-[:HAS_ORDER]-(O:Order),match (A:Account)-[:HAS_CONVERSATION]-(C:Conversation) where A.eDate >'2019-01-31' and O.orderStatus in ['Completed','Completed order'] and PS.productServiceName contains 'Self' return count(distinct(C.ConversationId))
I get the following error
Neo.ClientError.Statement.SyntaxError: Invalid input '(': expected whitespace, comment, '=', node labels, MapLiteral, a parameter, a relationship pattern, ',', USING, WHERE, LOAD CSV, FROM, INTO, START, MATCH, UNWIND, MERGE, CREATE GRAPH >>, CREATE >> GRAPH, CREATE GRAPH, CREATE, SET, DELETE GRAPHS, DELETE, REMOVE, FOREACH, WITH, CALL, PERSIST, RELOCATE, RETURN, SNAPSHOT, UNION, ';' or end of input (line 1, column 164 (offset: 163))
"match (PS:PrdSer)<-[:HAS_PS]- (PR:Product)-[H:HAS_PRODUCT]-(A:Account)-[:HAS_ORDER]-(O:Order),match (A:Account)-[:HAS_CONVERSATION]-(C:Conversation) where A.eDate >'2019-01-31' and O.orderStatus in ['Completed','Completed order'] and PS.productServiceName contains 'Self' return count(distinct(C.ConversationId))
"
Is this the correct way to write multiple match statements?
Your help is appreciated
04-05-2020 08:14 AM
Hi @uprav,
Welcome to the community!!
Remove "," before second Match
match (PS:ProductService)<-[:HAS_PRODUCT_SERVICE]- (PR:Product{productType:'WA'})-[H:HAS_PRODUCT]-(A:Account{accountType:'CONSUMER'})-[:HAS_ORDER]-(O:Order)
match (A:Account{accountType:'CONSUMER'})-[:HAS_PERSONA]-(P:Persona)-[:HAS_CONVERSATION]-(C:Conversation) where A.establishedDate >'2019-01-31' and O.orderStatus in ['Completed','Completed order','CO'] and PS.productServiceName contains 'Self' return count(distinct(C.sourceKeyConversationId))
04-05-2020 09:43 AM
Thanks Vivek. That worked 🙂
04-05-2020 12:16 PM
Also keep in mind DISTINCT is a keyword, not a function. count(distinct C.sourceKeyConversationId)
is enough. The extra parens you used in yours are just being used as a logical grouping, which is helpful when evaluating a complex boolean or arithmetic expression that requires grouping, but is no-op in simple cases like this.
All the sessions of the conference are now available online