有这样一段语句
----创建测试数据
if object_id('tbTest') is not null
drop table tbTest
GO
create table tbTest(日期 int, 姓名 varchar(10),工作量 int)
insert tbTest
select 1991,'张三',1 union all
select 1991,'张三',1 union all
select 1991,'王五',1 union all
select 1992,'张三',1 union all
select 1992,'李四',1----交叉汇总
declare @sql varchar(8000)
set @sql = 'select 日期'
select @sql = @sql + ',' + 姓名 + '=sum(case 姓名 when ''' + 姓名 + ''' then 工作量 else 0 end)'
from tbTest group by 姓名
EXEC(@sql + ' from tbTest group by 日期')----清除测试环境
drop table tbTest
在MS sql server中的结果是/*结果
日期        李四       王五         张三          
----------- ----------- ----------- ----------- 
1991        0           1           2
1992        1           0           1
*/但是在Sybase中的结果是日期        李四               
----------- ----------- 
1991        0           
1992        1        这是为什么呢,怎样修改才能让在Sybase中的结果和在MS sql中的结果一样。