尝试执行以下SQL但为所有列提供无效列“open”等
insert into t ("Date","assignee","pkey","open","In Progress","Awaiting Release","Referred")
select date, assignee,pkey,open,[In Progress],[Awaiting Release],[referred] from (
SELECT Cast(Getdate() AS DATE) AS Date,
pname AS Status,
assignee,
pkey
FROM s JI,
k JS
WHERE JI.issuestatus = JS.id
AND JI.issuetype IN ( 21, 4 )
AND JS.pname IN( 'Open', 'In Progress', 'Awaiting Release', 'Referred' ))as source
PIVOT
(count([Status])
FOR [status] in ([Open],[In Progress],[Awaiting Release],[Referred])) as pvt
答案 0 :(得分:0)
不确定但是更新下面的第一个语句
insert into t ([Date],[assignee],[pkey],[open],[In Progress],[Awaiting Release],[Referred])
答案 1 :(得分:0)
OPEN是一个命令,因此您需要在其周围放置方括号以突出显示它是一个字段
insert into t ("Date","assignee","pkey","open","In Progress","Awaiting Release","Referred")
select date, assignee,pkey,[open],[In Progress],[Awaiting Release],[referred] from (
SELECT Cast(Getdate() AS DATE) AS Date,
pname AS Status,
assignee,
pkey
FROM s JI,
k JS
WHERE JI.issuestatus = JS.id
AND JI.issuetype IN ( 21, 4 )
AND JS.pname IN( 'Open', 'In Progress', 'Awaiting Release', 'Referred' ))as source
PIVOT
(count([Status])
FOR [status] in ([Open],[In Progress],[Awaiting Release],[Referred])) as pvt