Change this
CASE
WHEN buySell = 'Buy' THEN AVG(salesTransactions.BuyPrice) AS AveragePrice,
WHEN buySell = 'Sell' THEN AVG(salesTransactions.SellPrice) AS AveragePrice,
END CASE;
to
CASE buySell
WHEN 'Buy' THEN AVG(salesTransactions.BuyPrice)
WHEN 'Sell' THEN AVG(salesTransactions.SellPrice)
END AS AveragePrice,
In the end it should look like this:
DELIMITER//
CREATE PROCEDURE procStats (IN buySell varchar(4))
BEGIN
SELECT
CASE buySell
WHEN 'Buy' THEN AVG(salesTransactions.BuyPrice)
WHEN 'Sell' THEN AVG(salesTransactions.SellPrice)
END AS AveragePrice,
MONTHNAME(salesTransactions.DateOfTransaction) as TransactionMonth
FROM
salesTransactions
GROUP BY
TransactionMonth
LIMIT 6;
END//
I fixed some more syntax errors.