According to your current attempt where
clause should go before group by
clause
SELECT something.CustomerName, something.CustomerAge,
SUM(cars.Price) AS Amount
FROM cars
INNER JOIN something ON something.CustomerNo=Cars.CustomerNo
GROUP BY something.CustomerName, something.CustomerAge
HAVING SUM(cars.Price) > 200;
However, you actually need to apply your filter on Amount
but, you can't do that via where
clause for that you would need to apply having
clause filter rather than where
clause
My today advice is to use table alise
that could be more readable and easy to use/implement
SELECT s.CustomerName, s.CustomerAge,
SUM(c.Price) AS Amount
FROM cars as c -- use of alise to make it more effective or readable
INNER JOIN something as s ON s.CustomerNo = c.CustomerNo -- and use that alise everywhere entire the query
GROUP BY s.CustomerName, s.CustomerAge
HAVING SUM(c.Price) > 200;