How to Sum over a vertex's attribute

Hi team,

I want to create a sum over a vertex’s attribute. I have vertex as “CAG” and it has attribute “Member Count” . Now I want to extract the sum of members where “CAG” is active. I have written following query but its throwing error. Can anyone help me with that?

CREATE QUERY Member_Count_Active_CAGs(String Client_name) FOR GRAPH CAG_Contract_Graph{
  #Begin by initializing the set of all contracts
  pp = {CAG.*};
  #Get the number of specific type of CAG for a given client
  speific_CAGs = SELECT sum(pp.Mbr_count) FROM pp:p WHERE pp.Search_Company == Client_name and pp.Active_or_InActive  == "Active";
  PRINT "Total Member Count of Active CAGs for " + Client_name+ " is " + to_string(speific_CAGs);
  PRINT speific_CAGs;
}

It will look a little like the following. I recommend the GSQL101 course to get a primer on what accumulators are and how they work. It is one of TG’s super-powers!

CREATE QUERY Member_Count_Active_CAGs(String Client_name) FOR GRAPH CAG_Contract_Graph{

    SumAccum <INT> @@sum_CAGS;

    #Begin by initializing the set of all contracts
    pp = {CAG.*};

    #Get the number of specific type of CAG for a given client
    pp = SELECT p
    FROM pp:p 
    WHERE p.Search_Company == Client_name and p.Active_or_InActive == “Active”
    POST-ACCUM @@sum_CAGS += p.Mbr_count;

    PRINT "Total Member Count of Active CAGs for " + Client_name+ " is " + to_string(@@sum_CAGS);
    PRINT @@sum_CAGS;
}