I have a function that I wrote to return a tax rate for a list of records but I want to be able to sum by the return tax rate but I get the following error "Cannot use an aggregate or a subquery in an expression used for the group by list of a GROUP BY clause
get_tax_rate" is the function I wrote to get the tax rate.
SELECT (select * from get_tax_rate([ship city],[ship state])) as [Tax Rate],
sum(Cost) as cost,sum([Final Ship Cost]) as [ship cost],
sum([misc cost]) as delivery,[ship city],[ship state],
FROM orders
where exists (select item from tandem_items where item=[product name] ) and
([ship date]>=@stdate and [ship date]<=@enddate)
group by (select * from get_tax_rate([ship city],[ship state]))
-George
Microsoft SQL Server MVP My Blogs SQLCop twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.