I am using a database called salesshort used mostly for learning MySQL. I am trying to create a stored procedure but for some odd reason when I run my code is not even creating the store procedure I think my syntax is wrong.
here are the instructions and my code.
Create a stored procedure ‘gbSaleP’ that returns the following ‘order types’: "we are loosing money" if the actual profit for each order (i.e., OrderNumber)- is lower than or equal to zero; "good sale" if the difference between potential profit and actual profit is $2500 or lower; and "bad sale" if the difference between potential profit and actual profit is greater than $2500.
delimiter // create procedure gbSaleP ( in orderNumber int(10), out SaleStatus varchar (40)) begin set gbsaleP = (select sum(o.quantityOrdered*p.MSRP - o.quantityOrdered*p.buyPrice) - abs(sum(o.quantityOrdered*o.priceEach - o.quantityOrdered*p.buyPrice)) from orderdetails as o join products as p using(productCode) group by orderNumber having porderNumber = orderName); if gbSaleP <= 2500 then set SalesStatus = "good sale" elseif gbSaleP => 2500 then set SaleStatus = "bad sale" else set gbSaleP = "unknown" end if; end; delimiter //