注册 登录
编程论坛 SQL Server论坛

[求助]表的显示问题

yanghao 发布于 2007-08-16 15:22, 520 次点击

我想把这个显示 年 姓名 休假总天数
2000 蝴蝶 10
2001 蝴蝶 15
2000 海藻 11
2001 海藻 25


改为这个显示 姓名 2000 2001
蝴蝶 10 15
海藻 11 25

用到以下语句,可是老出错,那为大虾帮忙改一下

Transform sum(年休假期) as 休假总天数
select 年,姓名
from 员工假期表
group by 姓名
pivot 年
这个查询语句有什么问题呢?为什么老提示错误呢???????
提示第一行有错误????帮忙解决一下啊。

[此贴子已经被作者于2007-8-16 15:23:54编辑过]

1 回复
#2
xinzheng2007-08-20 13:11
回复:(yanghao)[求助]表的显示问题

select nian,xm,jq as 2000 into #1 from aa where nian='2000'
select nian,xm,jq as 2001 into #2 from aa where nian='2001'

select aa.xm,#1.2000,#2.2001 from aa a,#1 b,#2 c where a.xm=b.xm and a.xm=c.xm

drop table #1
drop table #2

1