Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Data Format for Aggregate Fuctions

Dear All,
I am trying for the first time the "sum" aggregate function for a controller in Code on Time
Every time I use the "sum" aggregate function in a calculated field, I get errors stating that I cannot perform an aggregate function on an expression containing an aggregate or subquery.
Is there a way to rewrite this code that can be adapted for code on time use of aggregate functions.
Below is a snippet of my calculated field SQL formula

select sum((Price*Quantity)*(1-order_items.Discount))+
(Sum(Price*Quantity*(1-order_items.Discount))*vat_taxes*vat_rate)+
(SUM(Price*Quantity*(1-order_items.Discount))*wht_taxes*wht_rate)
from order_items
where order_id = orders.order_id

The error message I get:
Component: view1
Controller: AdvertReports; View: advertsreports; Timed out: false; Status Code: HSR;
Exception: System.Data.SqlClient.SqlException
Message: Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

1 person has
this question
+1
Reply