Reputation: 16264
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
.
Upvotes: 0
Views: 421
Reputation: 1
ORDER BY DATE(date
) DESC, TIME(date
) ASC;
I hope my answer can help you!
Upvotes: 0
Reputation: 9365
Cast to date
and then to time
ORDER BY
CAST([Date] AS date) DESC
,CAST([Date] AS time) ASC
Upvotes: 1