34,590
社区成员
发帖
与我相关
我的任务
分享
--SQL Server 2000
select id = identity(1, 1), *
into #tmp
from Stuinf
order by 学号
select sum(成绩)
from #tmp
where id % 2 = 1
drop table #tmp
--SQL Server 2005
select sum(t.成绩)
from
(select id = row_number() over(order by 学号), 成绩
from Stuinf) as t
where t.id % 2 = 1
select id=itentity(int,1,1),* into #temp from stuinf
select sum(成绩) from #temp where id%2=1
select identity(int,1,1) as id,* into # from stuinf
select 姓名,avg(成绩)
from #
where id%2 =1
gruop by 姓名