declare @sql varchar(8000)
set @sql = 'select 合营标识,数据类型,报表收敛一层,'
select @sql = @sql + 'sum(case year_month when '''+year_month+'''
then USD else 0 end) as '''+year_month+''','
from (select distinct year_month from 合营数据) as a
select @sql = left(@sql,len(@sql)-1) + ' from 合营数据 group by 合营标识,数据类型,报表收敛一层'
exec(@sql)
go执行上述语句后,只提示"Command(s) completed successfully.",怎么看不到查询结果?
set @sql = 'select 合营标识,数据类型,报表收敛一层,'
select @sql = @sql + 'sum(case year_month when '''+year_month+'''
then USD else 0 end) as '''+year_month+''','
from (select distinct year_month from 合营数据) as a
select @sql = left(@sql,len(@sql)-1) + ' from 合营数据 group by 合营标识,数据类型,报表收敛一层'
exec(@sql)
go执行上述语句后,只提示"Command(s) completed successfully.",怎么看不到查询结果?
declare @sql varchar(8000)
set @sql = 'select 合营标识,数据类型,报表收敛一层,'
select @sql = @sql + 'sum(case year_month when '''+year_month+'''
then USD else 0 end) as '''+year_month+''','
from (select distinct year_month from 合营数据) as a
select @sql = left(@sql,len(@sql)-1) + ' from 合营数据 group by 合营标识,数据类型,报表收敛一层'
print @sql---l楼说的是在这里添加print,查看你sql语句,看看是否有结果
--exec(@sql)
go
then USD else 0 end) as '''+year_month+''','-----then USD else 0 end) as year_month,'
“select 合营标识,数据类型,报表收敛一层,sum(...)”这样检查下你的sql语句是否有问题……