按日期排序desc,但在日期顺序asc(Order by date desc, but within day order by time asc)
我有一个表,其中有一个Date (smalldatetime)列。 我需要order by Date DESC ,但是每天都要order by Date ASC 。 输出应该像:
Date 2017-01-31T09:00:00Z 2017-01-31T17:00:00Z 2017-01-28T09:00:00Z 2017-01-28T17:00:00Z 2017-01-25T09:00:00Z 2017-01-25T17:00:00Z ...这样的查询可能吗?
如果有任何帮助,则数据最多包含同一Date的两行。
I have a table in which there is a Date (smalldatetime) column. I need to order by Date DESC, but within each day to order by Date ASC. The output should be like:
Date 2017-01-31T09:00:00Z 2017-01-31T17:00:00Z 2017-01-28T09:00:00Z 2017-01-28T17:00:00Z 2017-01-25T09:00:00Z 2017-01-25T17:00:00Z ...Is such a query possible?
If it's of any help, the data contains a maximum of two rows for the same Date.
最满意答案
铸就date
ORDER BY CAST([Date] AS date) DESC ,CAST([Date] AS time) ASCCast to dateand then to time
ORDER BY CAST([Date] AS date) DESC ,CAST([Date] AS time) ASC更多推荐
发布评论