--统计
set @collSql='select
sum(case Ca_IssueType when 0 then 1 else 0 end) as IssueCount,
sum(case when Ca_IssueType>0 then 1 else 0 end) as ReIssueCount,
sum(case Ca_IssueType when -1 then 1 else 0 end) as ChangeNoFingerCount,
sum(case when Ca_IssueType>-1 and Ca_ICType=0 then 1 else 0 end) as HasFingerCount,
sum(case when Ca_IssueType>-1 and Ca_ICType=1 then 1 else 0 end) as NoFingerCount,
sum(case when Ca_IssueType>-1 and Ca_IcNumType=1 then 1 else 0 end) as StuCardCount,
sum(case when Ca_IssueType>-1 and Ca_IcNumType=2 then 1 else 0 end) as TchCardCount
from ('+@mainSql+') t1'
EXECUTE(@collSql)

05-07 15:24