sql server 2000 排序
我现在有一个foodtb表,我想让结束日期大于当前当前日期升序,结束日期小于当前日期降序
------解决方案--------------------declare @t table(
id int identity(1,1),
begintime datetime,
endtime datetime
)
insert @t(begintime,endtime)
select '2005-01-01 ', '2005-01-02 '
union all select '2005-01-01 ', '2005-01-03 '
union all select '2005-01-01 ', '2004-01-03 '
union all select '2005-01-01 ', '2004-01-03 '
select * from @t
order by (case when endtime> begintime then id else -id end)
---这个意思吗?感觉楼主表达的太含糊了