I have been working on this and I understand the declare statements, but I don't understand it when there needs to be more than 2 declare statments. I am supposed to Update the discounts table to store #7896 where the type is initial customer, set the value of one variable equal to the amount of the maximum discount in the discount table. I named this variable highDiscount
. Set the value of the next variable equal to the store name that has the highest discount (found in step 2 above). I named this variable storeName
. Multiply the maximum discount by 10% and put the result into the third variable. I named this variable discountAmount
. Add the result from discountamount
to the current max discount and assign the value to the fourth variable. I named this variable totalNewDiscount
.
This is what I have:
Use pubs UPDATE dbo.discounts Set Stor_Id = '#7896'Declare @highDiscount money; Set @highDiscount = (Select MAX(discounts) From [dbo].discounts); Select @highDiscounts; Declare @ storeName money; Set @storeName =(SELECT Max(discounttype)FROM dbo.discounts) Declare @discountAmount money; Set @discountAmount = @discountAmount * 10%
At the time this is what I have and am trying to figure out how to add the result from the discount amount to the current max discount and assign the value to the forth variable. I know i could do something like SET @TotalNewDiscount = @discountAmount + @highDiscount.
But to me I think I have declared too many variables. Now am I able to have all the variables together but are they doing what they are suppose to do?