select identity(int,1,1) as id,* into # from stuinfselect 姓名,avg(成绩) from # where id%2 =1 gruop by 姓名
select id=itentity(int,1,1),* into #temp from stuinf select sum(成绩) from #temp where id%2=1
--SQL Server 2000 select id = identity(1, 1), * into #tmp from Stuinf order by 学号select sum(成绩) from #tmp where id % 2 = 1drop 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
if object_id('A') is not null drop table A go create table A(学号 int,姓名 varchar(20),成绩 int) insert A select 1, '张三', 70 union all select 3, '李四', 75 union all select 4, '王五', 72 declare @t table(id int identity(0,1),学号 int,姓名 varchar(20),成绩 int) insert @t select * from A select sum(成绩) as 奇数行总成绩 from @t where id%2=0
from #
where id%2 =1
gruop by 姓名
select id=itentity(int,1,1),* into #temp from stuinf
select sum(成绩) from #temp where id%2=1
--SQL Server 2000
select id = identity(1, 1), *
into #tmp
from Stuinf
order by 学号select sum(成绩)
from #tmp
where id % 2 = 1drop 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
drop table A
go
create table A(学号 int,姓名 varchar(20),成绩 int)
insert A
select 1, '张三', 70 union all
select 3, '李四', 75 union all
select 4, '王五', 72
declare @t table(id int identity(0,1),学号 int,姓名 varchar(20),成绩 int)
insert @t select * from A
select sum(成绩) as 奇数行总成绩 from @t where id%2=0