select * from tb1 order by col1 desc, col2 asc 假设得到结果 6 8 3 2 0 我要得到 0 2 3 8 6 希望在不改动原来语句条件的情况下,再加一个嵌套得到倒序结果
--试试,但这种倒序与原始不排序有什么区别? select * from ( select top 无穷大 * from tb1 order by col1 desc, col2 asc ) a order by col1,col2
select tt.*,id=identity(int,1,1) into #i from (select * from tb1 order by col1 desc, col2 asc)ttselect * from (select tt.*,id=identity(int,1,1) into #i from (select * from tb1 order by col1 desc, col2 asc)tt)ttt order by id desc
假设得到结果
6
8
3
2
0
我要得到
0
2
3
8
6
希望在不改动原来语句条件的情况下,再加一个嵌套得到倒序结果
select * from (
select top 无穷大 * from tb1 order by col1 desc, col2 asc
) a order by col1,col2
(select * from tb1 order by col1 desc, col2 asc)ttselect * from
(select tt.*,id=identity(int,1,1) into #i from
(select * from tb1 order by col1 desc, col2 asc)tt)ttt
order by id desc
临时表也不能用,记录太多