开发者

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.


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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜