declare @sql varchar(8000)
set @sql ='select Name as 姓名'
select @sql = @sql+' , max(case Subject when ''' + Subject + ''' then Result else 0 end) Subject'
from (select distinct Subject from tb) as a
set @sql = @sql + ' from tb group by name'
exec(@sql)
这个Sql 语句 哪里错了 ,找了半天也没找出来,求大神 帮下忙
from (select distinct Subject from tb) as a
这个你怎么在单引号外?
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare @sql varchar(800)
set @sql ='select Name as 姓名'
select @sql = @sql' at line 1
运行之后的错误 ,不知道哪里写错了