I'm doing some computation with the population values of the subcatchments, and I'm trying to compute the cumulative values using SUM and then I store it in the user define column, but when I apply the Sum to one of the user defined columns I get this errors.
user_number_2 -used in aggregate function but does not contain anything to aggregate.
Code:
LIST $nodeID STRING;
//Create a list with string values
SELECT SELECTED DISTINCT node_id INTO $nodeID FROM [All Nodes];
//Store distinct node values also make it scalar.
LET $i =1;//Variable for the loop
WHILE $i<=LEN($nodeID);
//start of While loop
DESELECT ALL FROM [All Nodes];
SELECT FROM [All Nodes] WHERE node_id= AREF($i,$nodeID);
UPDATE [ALL Links] SET $link_selected = 0;
UPDATE [ALL Nodes] SET $node_selected = 0;
UPDATE SELECTED SET $node_selected = 1;
SELECT FROM [All Nodes] WHERE $node_selected = 1;
UPDATE Subcatchment SET $subcatchment_selected =0;
UPDATE SELECTED SET subcatchments.$subcatchment_selected =1;
DESELECT ALL From Subcatchment;
SELECT FROM Subcatchment WHERE $subcatchment_selected =1;
SELECT SELECTED (population) INTO $Population_1 FROM Subcatchment;
SELECT FROM [All Nodes] WHERE node_id= AREF($i ,$nodeID);
UPDATE SELECTED SET user_number_1 = $Population_1 ;
// Moving the Population value to the user define
UPDATE SELECTED SET user_number_2= user_number_1 * 150 / 25;
UPDATE SELECTED SET user_number_3 = SUM( user_number_2);
//Stores values inside the subcatchment
UPDATE Subcatchment SET user_number_1 =
node.user_number_1, user_number_2 = node.user_number_2 WHERE subcatchment_id = node.node_id;
LET $i=$i+1;
//Increment
WEND;
// Terminator of the While Loop
DESELECT ALL FROM Subcatchment;