-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
|