Hi,
I am calculating Sum of the "UsrAmountForTheMonth" column from several records but every time it returns 0.
I didn't understand why the same is happening with Max and Count funtion as well.
Please help me with this.
Many thanks.
Like
1 comments
13:38 Jul 10, 2020
Dear Akshit,
Everything seems to be correct with the code itself. I tried a very similar code with the OOB tables and it returned correct result:
public void Execute(UserConnection userConnection) { var result = ""; var sel = new Select(userConnection) .Column(Func.Sum("Order", "Amount")).As("OrderAmount") .From("Order") .Where("AccountId").IsEqual(new Select(userConnection) .Column("Id") .From("Account") .Where("Name").IsEqual(Column.Parameter("Accom (sample)"))) .And("StatusId").IsNotEqual(new Select(userConnection) .Column("Id") .From("OrderStatus") .Where("Name").IsEqual(Column.Parameter("2. Confirmation"))) as Select; result = sel.ExecuteScalar<int>().ToString(); Console.WriteLine(result); }
You get 0 most likely because no records match the filter. Please run this query in SQL (SQL executor if your instance is in the cloud) and check what result you get.
Best regards,
Dennis
Show all comments