怎么给一个字段两种排序?
例如:
fieldname DatetimeOfRun
data 2008-05-08 20:08:08
2008-05-01 21:08:08
2008-05-03 22:08:08
2008-02-08 20:08:08
2008-02-08 21:08:08
2008-02-08 10:08:08
日期按照逆排、时间按照顺排序
fieldname DatetimeOfRun
data
2008-05-08 20:08:08
2008-05-03 22:08:08
2008-05-01 21:08:08
2008-02-08 10:08:08
2008-02-08 20:08:08
2008-02-08 21:08:08
------解决方案--------------------select * from tb order by convert(varchar(10),DatetimeOfRun,120) desc , right((varchar(19),DatetimeOfRun,120),9) asc
------解决方案--------------------Select * From TableName
Order By Convert(Varchar(10), DatetimeOfRun, 120) Desc, Convert(Varchar, DatetimeOfRun, 108)
------解决方案--------------------Create Table TEST
(fieldname Varchar(10),
DatetimeOfRun SmallDateTime)
Insert TEST Select 'data ', '2008-05-08 20:08:08 '
Union All Select 'data ', '2008-05-01 21:08:08 '
Union All Select 'data ', '2008-05-03 22:08:08 '
Union All Select 'data ', '2008-02-08 20:08:08 '
Union All Select 'data ', '2008-02-08 21:08:08 '
Union All Select 'data ', '2008-02-08 10:08:08 '
GO
Select * From TEST
Order By Convert(Varchar(10), DatetimeOfRun, 120) Desc, Convert(Varchar, DatetimeOfRun, 108)
GO
Drop Table TEST
--Result
/*
fieldname DatetimeOfRun
data 2008-05-08 2