Results 1 to 2 of 2

Thread: Issues using the SUM function in SQL

  1. #1

    Join Date
    Jun 2018

    Issues using the SUM function in SQL

    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.

    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; 
    // Terminator of the While Loop
    DESELECT ALL FROM Subcatchment;

  2. #2

    Innovyze Employee

    Join Date
    Mar 2013
    Hi Zesima29,
    According to statistics help page of InfoWorks ICM, SUM( user_number_2) should have user_number_2 as a collection of numbers.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts