一个查询语句有多个排序条件:
select.....order by col1 desc, col2 asc
需要在综合这些条件得到的结果,再全部倒序,应该怎么写?

解决方案 »

  1.   

    因为首次排序的条件是不定的,有可能几个,而且desc,asc也不确定,希望在得到结果后再全部到序,这时候已经没有唯一的条件了,有可能用一个语句写出吗?
      

  2.   

    select * from tb1 order by col1 desc, col2 asc
    假设得到结果
    6
    8
    3
    2
    0
    我要得到
    0
    2
    3
    8
    6
    希望在不改动原来语句条件的情况下,再加一个嵌套得到倒序结果
      

  3.   

    --试试,但这种倒序与原始不排序有什么区别?
    select * from (
    select top 无穷大 * from tb1 order by col1 desc, col2 asc
    ) a order by col1,col2
      

  4.   

    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
      

  5.   

    WangZWang(阿来)的方法不是我想要的,我不希望再后面再另外加上和原来条件有关的语句
    临时表也不能用,记录太多