Skip to content

Commit

Permalink
Create IfElseTest.gsql
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxiw authored Jan 21, 2025
1 parent 2356851 commit fc869c1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions demos/guru_scripts/docker/tutorial/4.x/script/IfElseTest.gsql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
USE GRAPH financialGraph
CREATE OR REPLACE QUERY IfElseTest () SYNTAX V3 {

SumAccum<INT> @@isBlocked;
SumAccum<INT> @@unBlocked;
SumAccum<INT> @@others;

S1 = SELECT a
FROM (a:Account)
ACCUM
IF a.isBlocked THEN @@isBlocked += 1
ELSE IF NOT a.isBlocked THEN @@unBlocked += 1
ELSE @@others += 1
END;

PRINT @@isBlocked, @@unBlocked, @@others;

STRING drink = "Juice";
SumAccum<INT> @@calories = 0;

//if-else. Top-statement level. Each statement
//needs to end by a semicolon, including the “END”.

IF drink == "Juice" THEN @@calories += 50;
ELSE IF drink == "Soda" THEN @@calories += 120;
ELSE @@calories = 0; // Optional else-clause
END;
// Since drink = "Juice", 50 will be added to calories

PRINT @@calories;
}

INSTALL QUERY IfElseTest

RUN QUERY IfElseTest()

0 comments on commit fc869c1

Please sign in to comment.