开发者

SQL Insert from other table into new table

开发者 https://www.devze.com 2023-04-11 07:12 出处:网络
CREATE TABLE #Temporary ( HoursThisYear int, HoursLastYear int, HoursBefore2010 int ) INSERT INTO #Temporary (HoursThisYear)
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.


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

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


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

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


this should work

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

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

精彩评论

暂无评论...
验证码 换一张
取 消