I would like to add all the rows together using mvc ,the rows are name and total spending ,these 2 rows are saved inside database, now i would like to add one more row which is total spending for all. May I know how could I get it done? To sum up , i would need to have a grand total column which calculates all the total spending of each person . Sorry I am new to programming.
Example:
Name: James
Total Spending : $5
Name: Tina
Total Spending : $15
Then there will be a Total Spending for everyone which calculate both james and tina spending , so how do I get the calculation for all the total spending ?
These are the codes: Currently I could only get the total price for one row only with
foreach (var DataSheet in db.Query(query)){
var spending = DataSheet.Spending;
totalSpending = spending + 2
}
I need to add the total spending for 2 different people and put it inside the AllTSpending row