Can you please help me with this? I am trying to calculate the total of all the rows in my Price Table, but the values never add up, and now it doesn’t seem to calculate anymore either.
I have the following:
@{
decimal money = 0.00m;
var prices = "SELECT Price, SUM(Price) FROM PriceTable GROUP BY Price";
var database = Database.Open("MYDB");
database.QuerySingle(prices);
money = prices.AsDecimal();
}
And somewhere in my HTML I type:
@money // to display the totalAmount
Am I doing it right? I’ve searched for this, but surprisingly there seems to be not much info about this, I’m probably not using the right keywords though.
Thank you
change
to
IF all you want is the sum of all rows, the grouping is not required.
Also;