1 SELECT *
2 FROM my_table
3 WHERE 1
4 ORDER BY
5 CASE price WHEN 0 THEN 1
6 ELSE -1
7 END ASC, price asc, id asc
8
1SELECT orders.status, orders.created_at
2FROM `orders`
3ORDER BY
4 status='new' DESC,
5 status='processing' DESC,
6 CASE WHEN status IN ('new', 'processing') THEN created_at END ASC,
7 CASE WHEN status NOT IN ('new', 'processing') THEN created_at END DESC