日期排序
有表table字段cDate,cHour,cMinute值形如: '2007-09-10 ', '5 am ', '35 '
其中cHour所有的值如下,(前面的比后面的时间要早,特别注意12pm和12am的位置)
'1 am ', '2 am ', '3 am ', '4 am ', '5 am ', '6 am ', '7 am ', '8 am ', '9 am ', '10 am ', '11 am ', '12 pm ',
'1 pm ', '2 pm ', '3 pm ', '4 pm ', '5 pm ', '6 pm ', '7 pm ', '8 pm ', '9 pm ', '10 pm ', '11 pm ', '12 am '
要求写一个存储过程,将所有记录排序,按照cDate,cHour,cMinute的先后顺序.
cDate相同的看cHour,cHour相同的看cMinute
------解决方案--------------------select * from table order by cDate,cast(cHour as datetime),cast(cMinute as int)