SQL Server : assistance with INSERT INTO

139 views Asked by At

I have a problem where I need to create new entries in the SpecialOfferProduct table. I am applying my created discount (SpecialOfferID = 20) to all products that have an inventory greater than 1800 but I can't figure out what I am doing wrong. this is my code.

INSERT INTO Sales.SpecialOfferProduct (ProductID SpecialOfferID)
    SELECT ProductID 
    FROM Production.ProductInventory 
    GROUP BY ProductID 
    HAVING SUM(Quantity) > 1800, 20 AS SpecialOfferID;

It's from the AdventureWorks2012 database

Thanks

1

There are 1 answers

0
ali azizan On BEST ANSWER

did you means it

INSERT INTO Sales.SpecialOfferProduct (ProductID ,SpecialOfferID)
SELECT ProductID, 20 AS SpecialOfferID FROM Production.ProductInventory 
GROUP BY ProductID 
HAVING sum(Quantity) > 1800;