Skip to content

Commit

Permalink
add q2.gsql
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingxi Wu authored and Mingxi Wu committed Sep 12, 2024
1 parent 8af9e99 commit 8dc6196
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions demos/guru_scripts/docker/tutorial/4.x/script/q2.gsql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
USE GRAPH financialGraph

# create a query
CREATE OR REPLACE QUERY q2 (string accntName) SYNTAX v3 {

// declare an local sum accumulator; you can keep adding values into it
// "local accumulator" means each vertex will have an accumulator of
// the declared type and can be accumulated into based on the
// FROM clause pattern.
SumAccum<int> @totalTransfer = 0;

// match an edge pattern-- symbolized by ()-[]->()
// v is a vertex set variable holding the selected vertex set
v = SELECT b
FROM (a:Account {name: accntName})-[e:transfer]->(b:Account)
//for each matched row, do the following accumulation
ACCUM b.@totalTransfer += e.amount;

//output each v and their static attribute and runtime accumulators' state
PRINT v;

}

#compile and install the query as a stored procedure
install query q2

#run the query
run query q2("Scott")

0 comments on commit 8dc6196

Please sign in to comment.