report service 中怎么调用sql function
2017-02-26
展开全部
生成数据透视表
set @sql = 'SELECT [name], ' select @sql = @sql + 'sum(case book when '+quotename(book,'''')+' then saledNumber else 0 end) as ' + quotename(book)+',' from s group by book select @sql = left(@sql,len(@sql)-1) select @sql = @sql + ', sum(saledNumber) as [sum] from s group by [name]' select @sql exec(@sql)
set @sql = 'SELECT [name], ' select @sql = @sql + 'sum(case book when '+quotename(book,'''')+' then saledNumber else 0 end) as ' + quotename(book)+',' from s group by book select @sql = left(@sql,len(@sql)-1) select @sql = @sql + ', sum(saledNumber) as [sum] from s group by [name]' select @sql exec(@sql)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询