Search code examples
sqlselectinsertcreate-table

SQL Insert from other table into new table


CREATE TABLE #Temporary
(
HoursThisYear int,
HoursLastYear int,
HoursBefore2010 int
)

INSERT 
INTO #Temporary (HoursThisYear)
SELECT SUM(Hours) WHEN Year = '2011' FROM WorkFlow

I am very new at this, and not sure what I am doing.


Solution

  • Assuming you're looking for help on the INSERT syntax.

    INSERT INTO #Temporary 
        (HoursThisYear)
        SELECT SUM(Hours) 
            FROM WorkFlow
            WHERE Year = '2011'