sqlserver怎么建临时表?
declare@sqlvarchar(2000)declare@lievarchar(2000)set@sql=''set@lie=''select@sql=@sql+'...
declare @sql varchar(2000)declare @lie varchar(2000)set @sql=''set @lie=''select @sql=@sql+',case when sum(case when pzmc='''+pzmc+''' then sl end) is null then 0 else sum(case when pzmc='''+pzmc+''' then sl end) end as ['+pzmc+']'from Z_YidaiZajiaozhongShengchan where nian='2008' and jidu='春' and shsftg='通过' group by pzmcselect @lie=@lie+'+case when sum(case when pzmc='''+pzmc+''' then sl end) is null then 0 else sum(case when pzmc='''+pzmc+''' then sl end) end'from Z_YidaiZajiaozhongShengchan where nian='2008' and jidu='春' and shsftg='通过' group by pzmcexec ('select case when (grouping(tbdw)=1) then ''合计'' else tbdw end as 场别 '+@sql+','+@lie+' as 合计 from Z_YidaiZajiaozhongShengchan where nian=''2008'' and jidu=''春'' and shsftg=''通过'' group by tbdw with rollup') 我想把上面查询出来的结果建成一个临时表或者是视图,应该怎么建啊?
展开
7个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询