Reputation: 3641
I have a query result (please refer below)
Current Result:
Paid Date
0000-00-00
2010-05-01
2011-06-02
2013-07-08
0000-00-00
In this situation I want to show all the unpaid first(with 0000-00-00 stamp) but also I need to achieve something like this result
Goal Result:
Paid Date
0000-00-00
0000-00-00
2013-07-08
2011-06-02
2010-05-01
What SQL Query I will write to obtain this output?
Upvotes: 1
Views: 170
Reputation: 4858
You can achieve this using find_in_set.
Something like.. ORDER BY find_in_set(date_field, '0000-00-00')
OR using field as FIELD(date_field, '0000-00-00') DESC
Upvotes: 3