首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

在查询的结果集中怎样去掉第一条记录?该如何处理

2012-04-10 
在查询的结果集中怎样去掉第一条记录?记录有很多条,在查询的结果集中只把第一条记录去掉,剩下的记录保留不

在查询的结果集中怎样去掉第一条记录?
记录有很多条,在查询的结果集中只把第一条记录去掉,剩下的记录保留
不是删除第一条记录,而是不显示第一条记录
create table #test1
(
id int

)
insert into #test1 select 1
insert into #test1 select 10
insert into #test1 select 11
insert into #test1 select 15
insert into #test1 select 16
insert into #test1 select 18
insert into #test1 select 19

select * from #test1
drop table #test1

怎样不显示第一条记录

[解决办法]

SQL code
select id from (select row_number()over(order by getdate()) as rownum,* from tbl)awhere rownum>=2
[解决办法]
select * from #test1
except
select top 1 * from #test1
[解决办法]
SQL code
select ID from (select ROW_NUMBER() over(order by id )rn,* from #test1 )a where rn>1
[解决办法]
select * from #test1
except
select * from #test1 where id=1

--or
select * from #test1
except
select top 1 * from #test1

热点排行
Bad Request.