哪位兄弟知道在Sql server中如何让多天数据的某一天排序到最前边。

解决方案 »

  1.   

    有两种方法:
    1)Select 字段1,字段2 from 表 
    order by (Case when 日期字段=指定日期 then 0 else 日期字段 end)
    2)用Union all来处理
    Select * from
    (Select '1'as PX,字段1,字段2 from 表 where 日期字段=指定日期
    Union all
    Select '2'as PX,字段1,字段2 from 表 where 日期字段<>指定日期) as S
    order by PX
      

  2.   

    create table t1(sj varchar(10))
    insert into t1
    select '2005-1-1' union all
    select '2005-7-2' union all
    select '2005-11-5' union all
    select '2005-12-8' union all
    select '2006-12-21' 
    select * from t1
    order by (case sj when '2005-11-5' then 0 else 1 end)--使'2005-11-5'排在最前面