Given:
- An array that contains distinct Name Values.
- A datatable with 2 String columns: Name values, cost
Problem:
I need to get the sum of the cost column, grouped under the same name value.
The values for the sum for each name value are also stored in another array, so as to match with the Name value array.
My solution:
I used the compute function of the datatable.
Convert.ToInt32(dt.Compute(“SUM(Convert(cost,‘System.Int32’))”,“Name Value= '”& nameArray.(counter).ToString &“'”))
My error:
Assign : Syntax error in aggregate argument: Expecting a single column argument with possible ‘Child’ qualifier
Please help!
Thank you!