Search code examples
sqlsql-serversql-insertadventureworks

SQL Server : assistance with INSERT INTO


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


Solution

  • 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;