34,590
社区成员
发帖
与我相关
我的任务
分享
select * from tb where id <max(id) order by id desc
select * from tb where id >min(id) order by id
select * from tb where id not in (select min(id) from tb) order by id
select * from tb where id not in (select max(id) from tb) order by id desc
select * from tb where id not in (select top 1 id from tb)
create table ta(id int,[name] char(4),type char(1) ,[money] numeric(12,2))
insert ta select 1,'aa','A',120
insert ta select 2,'ab','B',130
insert ta select 3,'ac','C',140
insert ta select 4,'ac','C',130
insert ta select 5,'ac','C',120
go
select *
from ta a
where id <> (select min(id) from ta )
drop table ta
/*
id name type money
----------- ---- ---- --------------
2 ab B 130.00
3 ac C 140.00
4 ac C 130.00
5 ac C 120.00
(所影响的行数为 4 行)
*/