34,590
社区成员
发帖
与我相关
我的任务
分享
create table tb(Lastreply varchar(20))
insert into tb select '2011-9-8 12:34:08'
insert into tb select '2011-9-7 12:12:50'
insert into tb select '2011-9-16 17:35:41'
go
select * from tb order by convert(datetime,Lastreply) desc
/*
Lastreply
--------------------
2011-9-16 17:35:41
2011-9-8 12:34:08
2011-9-7 12:12:50
(3 行受影响)
*/
go
drop table tb
create table tb(Lastreply datetime)
insert into tb select '2011-9-8 12:34:08'
insert into tb select '2011-9-7 12:12:50'
insert into tb select '2011-9-16 17:35:41'
go
select * from tb order by Lastreply desc
/*
Lastreply
-----------------------
2011-09-16 17:35:41.000
2011-09-08 12:34:08.000
2011-09-07 12:12:50.000
(3 行受影响)
*/
go
drop table tb
估计你的Lastreply是字符型的,所以导致
2011-9-16 17:35:41 在 2011-9-7 12:12:50 下面
因为判断到第7位时,1<7
order by convert(datetime,Lastreply) desc