I want to be able to sum a value returned from a scalar function but I get the following error. Can someone tell me the correct way to do this?
Cannot perform an aggregate function on an expression containing an aggregate or a subquery
dbo.get_price is my scalar function I created.
below is the select statement.
SELECT [Order Number],sum((select dbo.get_price([order date],[qty ordered]))) as price,sum([Final Ship Cost]) as [ship cost],
(select case when [shipping method]<>'San Diego Local Delivery' then 0 else sum([misc cost]) end) as [delivery Fee],[ship city],[ship state],
(select * from get_tax_rate([ship city],[ship state])) as [Tax Rate]
FROM millennium
where exists (select item from items where item=[product name] ) and
([ship date]>=@stdate and [ship date]<=@enddate)
group by [Order Number],[shipping method],[ship city],[ship state]
Cannot perform an aggregate function on an expression containing an aggregate or a subquery
dbo.get_price is my scalar function I created.
below is the select statement.
SELECT [Order Number],sum((select dbo.get_price([order date],[qty ordered]))) as price,sum([Final Ship Cost]) as [ship cost],
(select case when [shipping method]<>'San Diego Local Delivery' then 0 else sum([misc cost]) end) as [delivery Fee],[ship city],[ship state],
(select * from get_tax_rate([ship city],[ship state])) as [Tax Rate]
FROM millennium
where exists (select item from items where item=[product name] ) and
([ship date]>=@stdate and [ship date]<=@enddate)
group by [Order Number],[shipping method],[ship city],[ship state]