怎么给一个字段两种排序?
例如:
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
(fieldnameVarchar(10),
DatetimeOfRunSmallDateTime)
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
/*
fieldnameDatetimeOfRun
data2008-05-08 20:08:00
data2008-05-03 22:08:00
data2008-05-01 21:08:00
data2008-02-08 10:08:00
data2008-02-08 20:08:00
data2008-02-08 21:08:00
*/
[解决办法]
..........................................
[解决办法]
晚来一步
[解决办法]
鱼的方法不错
[解决办法]
呵可!!!!也学了点
[解决办法]
ACCESS這麼寫
select RunDate,RateData from RunRateInfo where CarBrandCode = '晋A00004 ' and (RunDate <= '2007-04-10 ' and RunDate> = '2007-04-01 ')
Order By Format(DatetimeOfRun, "yyyy-Mm-dd ") Desc, Format(DatetimeOfRun, "Hh-Nn-Ss ")