I’m trying to sort order by both timestamp and enum (main order timestamp, “sub-order” enum), but it seems only one or the other works.
It’s a very simple table called table:
id | task | date_estimated [timestamp] | status [enum]
I’ve tried:
select * from table order by date_estimated DESC, status DESC
which, should, in theory, give me something that is sub-sorted by enum status per date, right?
3/5/2012 added - gas up done - buy milk done - buy pencils
But, it’s giving me a jumble like
3/5/2012 done - buy milk added - gas up done - buy pencils
How do I write a query to sort like the first case?
Try
select * from table order by DATE(date_estimated) DESC, status DESCThe timestamp field includes hours/minutes/seconds so you’d get an odd order if you were looking for the actual date part considering the event would have to occur on the same second in order for the sub-group to make sense in your query.