SQL - I'm trying to find the average of all fields that meet a condition and I'm getting: invalid in the HAVING clause... Any help would be awesome.
use Pizza05
Select AVG(PizzaToppings.ToppingPrice + Products.ProductPrice) as Average
from OrderedProducts
Left Join PizzaToppings ON PizzaToppings.ToppingID = OrderedProducts.ToppingID
Inner Join Products ON Products.ProductID = OrderedProducts.ProductID
having OrderedProducts.QuantityOrdered > 10
You have to replace
having
withwhere
, sincehaving
is used to specify conditions on aggregate functions, not single columns. See here.