ALTER proc so_total_report
@columnName varchar(10)
as
declare @sql varchar(8000)
set @sql = 'select [email protected]+''
select @sql = @sql + ',SUM(case td when ''' + td + ''' then sar else 0 end) [' + td + '下]'
+',SUM(case td when ''' + td + ''' then sina else 0 end) [' + td + '入]'
+',SUM(case td when ''' + td + ''' then snoa else 0 end) [' + td + '未]'
from (select distinct td from so_jiaoqi) as a
set @sql = @sql + ' from so_jiaoqi group by [email protected]
print @sql
exec(@sql)
EXEC so_total_report 'tp'
?
?
?