How do you do CTE queries in neo4j? SAMPLE QUERY:
MATCH (rootTopic:Company)-[:Seller|Buyer]->(:SalesRelation) WHERE rootTopic.ID = 172096 MATCH (sellerCompanyTopic:Company)-[rel:Seller]->(sr:SalesRelation)-[rel2:Buyer]-(buyer:Company), sr<-[:PriceAgreement]-(contract:Contract) OPTIONAL MATCH p = shortestPath(rootTopic-[:Seller|Buyer*]-sellerCompanyTopic) WITH DISTINCT rootTopic, sellerCompanyTopic, buyer, contract, reduce( index = 0, type IN EXTRACT(r in relationships(p) | type(r))| case when index % 2 = 0 AND type = 'Buyer' then -1000 when index % 2 = 1 AND type = 'Seller' then -1000 ELSE index + 1 END ) AS Related WHERE rootTopic = sellerCompanyTopic OR rootTopic = buyer OR Related > 0 RETURN rootTopic.ID AS RootCompanyTopicID, sellerCompanyTopic.ID AS SellerTopicID, buyer.ID AS BuyerTopicID, contract.ID AS ContractTopicID, case when Related is null then 1 when Related < 0 then 0 ELSE Related END AS Depth ORDER BY RootCompanyTopicID, SellerTopicID, BuyerTopicID, ContractTopicID Best Regards, Ryan -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
