Skip to content

Commit

Permalink
Create c7.cypher
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxiw authored Jan 17, 2025
1 parent c65fb54 commit 2ce6088
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions demos/guru_scripts/docker/tutorial/4.x/cypher/c7.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
USE GRAPH financialGraph

// create a query
CREATE OR REPLACE OPENCYPHER QUERY c7 (datetime low, datetime high, string accntName) {
// a path pattern in ascii art () -[]->()-[]->()
// think the MATCH clause is a matched table with columns (a, e, b, e2, c)
// you can use SQL syntax to group by on the matched table
// Below query find 2-hop reachable account c from a, and group by the path a, b, c
// find out how much each hop's total transfer amount.
MATCH (a:Account)-[e:transfer]->(b)-[e2:transfer]->(c:Account)
WHERE e.date >= $low AND e.date <= $high
RETURN a, b, c, sum(DISTINCT e.amount) AS hop_1_sum, sum(DISTINCT e2.amount) AS hop_2_sum
}

install query c7

run query c7("2024-01-01", "2024-12-31", "Scott")

0 comments on commit 2ce6088

Please sign in to comment.