日期:2014-05-17 浏览次数:20537 次
select id,StartTime,EndTime,
(case when getdate() between StartTime and EndTime then 0 when getdate()<StartTime then 1 else 2 end) as LISTORDER, --判断商品即将开始(1)、正在进行中(0)、已经结束(2)
datediff(second,getdate(),EndTime) as dates,
datediff(second,getdate(),StartTime) as dates1
from [ceb_DiHuDB].[dbo].[ceb_P_TuanGou]
order by ...........
select id,StartTime,EndTime,
(case when getdate() between StartTime and EndTime then 0 when getdate()<StartTime then 1 else 2 end) as LISTORDER, --判断商品即将开始(1)、正在进行中(0)、已经结束(2)
datediff(second,getdate(),EndTime) as dates,
datediff(second,getdate(),StartTime) as dates1
from [ceb_DiHuDB].[dbo].[ceb_P_TuanGou]
order by 2
???
select id,StartTime,EndTime,
(case when getdate() between StartTime and EndTime then 0 when getdate()<StartTime then 1 else 2 end) as LISTORDER,
datediff(second,getdate(),EndTime) as dates,
datediff(second,getdate(),StartTime) as dates1
from [ceb_DiHuDB].[dbo].[ceb_P_TuanGou]
order by
case when getdate() between StartTime and EndTime then datediff(second,GETDATE(),StartTime) end ,
case when datediff(day,GETDATE(),StartTime)>=0 then datediff(day,GETDATE(),StartTime) end,
case when datediff(day,GETDATE(),StartTime)<0 then datediff(day,GETDATE(),StartTime) end desc