SQL怎样把查出来的结果集再倒序查询?

2025-03-22 03:52:20
推荐回答(4个)
回答1:

if object_id('tb') > 0 drop table tb
go
create table tb (sid int)
insert into tb select '1'
union all select '2'
union all select '3'
union all select '4'
union all select '5'
union all select '6'
union all select '7'
union all select '8'
union all select '9'
union all select '10'

select * from (select top 5 * from tb) t
order by t.sid desc

楼主直接给分吧、哈哈!

回答2:

select T.s_id from (select top 5 s_id from tableID order by s_id ) as T order by T.s_id desc

回答3:

select * from (select top 5 s_id from tableID order by s_id ) aa order by s_id desc

回答4:

Order by ...