declare @s varchar(8000)
set @s=''
select
@s=@s+','+a.ts_name+'|'+b.ts_name+'完成 =sum(case when type='+rtrim(a.ts_id)+' and subtype='+rtrim(b.ts_id)+' and ts_activeinactive=1 then 1 else 0 end)'
from Selection_Issuetype a,Selection_subtype b where a.ts_id=b.type order by a.ts_id,b.ts_id
set @s='select '+stuff(@s,1,1,'')+' from usr_incidents'
exec(@s)declare @s varchar(8000)
set @s=''
select
a.ts_name+'|'+b.ts_name+'完成 =sum(case when type='+rtrim(a.ts_id)+' and subtype='+rtrim(b.ts_id)+' and ts_activeinactive=1 then 1 else 0 end)'
from Selection_Issuetype a,Selection_subtype b where a.ts_id=b.type order by a.ts_id,b.ts_id
set @s='select '+stuff(@s,1,1,'')+' from usr_incidents'
exec(@s)
set @s=''
select
@s=@s+','+a.ts_name+'|'+b.ts_name+'完成 =sum(case when type='+rtrim(a.ts_id)+' and subtype='+rtrim(b.ts_id)+' and ts_activeinactive=1 then 1 else 0 end)'
from Selection_Issuetype a,Selection_subtype b where a.ts_id=b.type order by a.ts_id,b.ts_id
set @s='select '+stuff(@s,1,1,'')+' from usr_incidents'
exec(@s)declare @s varchar(8000)
set @s=''
select
a.ts_name+'|'+b.ts_name+'完成 =sum(case when type='+rtrim(a.ts_id)+' and subtype='+rtrim(b.ts_id)+' and ts_activeinactive=1 then 1 else 0 end)'
from Selection_Issuetype a,Selection_subtype b where a.ts_id=b.type order by a.ts_id,b.ts_id
set @s='select '+stuff(@s,1,1,'')+' from usr_incidents'
exec(@s)
set @s=''
select
@s=@s+',['+a.ts_name+'|'+b.ts_name+'完成] =sum(case when type='+rtrim(a.ts_id)+' and subtype='+rtrim(b.ts_id)+' and ts_activeinactive=1 then 1 else 0 end)'
from Selection_Issuetype a,Selection_subtype b where a.ts_id=b.type order by a.ts_id,b.ts_id
set @s='select '+stuff(@s,1,1,'')+' from usr_incidents'
exec(@s)