我想实现的就是查询一个表,,表里有一个预约时间字段和记录的创建时间字段 
比如预约时间字段是2009-02-20 20:31 现在时间是:2009-02-20 20:00  
在查询的时候是按着创建时间来排序的。也就是说最新发布的显示在最前面,如果现在时间到了2009-02-20 20:31的话,那就将这条记录放到最前面显示。[code=SQL]
select * from table order by  case  预约时间  when  now() then 现在时间 else 创建时间 end[/SQL]

解决方案 »

  1.   


    select * from table where 预约时间字段 >= 创建时间
    union all
    select * from table where 预约时间字段 < 创建时间
      

  2.   

    select * 
    from [table] 
    order by  
      case  when 预约时间>getdate() then 1 else 0 end,
      预约时间 desc
      

  3.   

    select *
    from
    (
    select * , 0 as cnt from table where  预约时间 =getdate()
    union 
    select * , 1 as cnt from table where  预约时间 <>getdate()
    ) A
    order by cnt 
      

  4.   

    修正一下select * 
    from [table] 
    order by  
      case  when convert(char(16),预约时间,120)=convert(char(16),getdate(),120) then 0 else 1 end,
      创建时间 desc
      

  5.   

    看LZ贴的里面有NOW函数
    应该是ACCESS数据库的吧