I need a MySQL conditional ORDER BY statement for a datetime field. I have a table with posts which I would like to order in the following way: all future posts
Try this:
ORDER BY post_status ASC, CASE post_status WHEN 'future' THEN POST_DATE END ASC, CASE WHEN post_status <> 'future' THEN post_date END DESC