34,838
社区成员




Select top 5 * From Test Where ID Not In Select Top (Select Count(*)-5 From Test) From Test
select top 5 * from table order by [你要排序的字段] desc
--1,按ID排序
select top 5 * from tb order by id
select top 5 * from tb order by id desc
--2不排序,如何从表中用SELECT语句提取最后10条数据
declare @num as int
select @num = count(*) from authors
set @num = @num - 10
declare @sql as varchar(200)
set @sql = 'select * from authors where au_id not in (select top ' + cast(@num as char) + ' au_id from authors)'
exec (@sql)