Skip to content

Commit

Permalink
Update q2a.gsql
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxiw authored Sep 12, 2024
1 parent 6fe3f2b commit d322609
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions demos/guru_scripts/docker/tutorial/4.x/script/q2a.gsql
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ USE GRAPH financialGraph

CREATE OR REPLACE QUERY q2a (string accntName) SYNTAX v3 {

SumAccum<int> @totalTransfer = 0;
//think the FROM clause is a matched table with columns (a, e, b)
//you can use SQL syntax to group by the source and target account, and sum the total transfer amount
SELECT a, b, sum(e.amount) INTO T
FROM (a:Account {name: accntName})-[e:transfer]->(b:Account)
GROUP BY a, b;

v = SELECT b
FROM (a:Account {name: accntName})-[e:transfer]->(b:Account)
ACCUM b.@totalTransfer += e.amount;

PRINT v;
//output the table in JSON format
PRINT T;

}

Expand All @@ -17,4 +18,3 @@ install query q2a

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

0 comments on commit d322609

Please sign in to comment.