日期:2014-05-18 浏览次数:20493 次
declare @tableC table (Id int,Time datetime) insert into @tableC select 301,'2011-03-01' union all select 301,'2011-03-03' union all select 301,'2011-03-04' union all select 304,'2011-03-05' union all select 301,'2011-03-08' union all select 304,'2011-03-07' select * from @tableC order by id ,time desc /* Id Time ----------- ----------------------- 301 2011-03-08 00:00:00.000 301 2011-03-04 00:00:00.000 301 2011-03-03 00:00:00.000 301 2011-03-01 00:00:00.000 304 2011-03-07 00:00:00.000 304 2011-03-05 00:00:00.000 */
------解决方案--------------------
select * from tableC
order by Id,Time desc
ID不排序是放不到一起去的
------解决方案--------------------
order by id,[time] desc
------解决方案--------------------
正常情况主键不能为空,其他为空的时候,排序desc现在在最上面。