34,589
社区成员
发帖
与我相关
我的任务
分享
create table tb(id int,dt varchar(10))
insert into tb select 1,'aa'
insert into tb select 2,'cc2'
insert into tb select 4,'fsa'
insert into tb select 7,'fe'
insert into tb select 12,'ewr'
insert into tb select 13,'tr'
insert into tb select 15,'ge'
insert into tb select 22,'he'
go
select id,dt from (select *,(select count(*) from tb where id<=a.id) as rn from tb a)t where rn%2=0
--ACCESS 中:
select id,dt from (select *,(select count(*) from tb where id<=a.id) as rn from tb a)t where rn mod 2=0
/*
id dt
----------- ----------
2 cc2
7 fe
13 tr
22 he
(4 行受影响)
*/
go
drop table tb