ORDER BY can contain an arbitrary expression, so you can evaluate those = 0 and assign them a higher value, which is sorted later:
SELECT * FROM products ORDER BY CASE WHEN quantity_in_stock = 0 THEN 1 ELSE 0 END ASC, product_name ASC
Due to the boolean evaluation of MySQL returning 1 or 0, you can simplify this as shown below. However, this will not work in all DBMSs:
SELECT * FROM products ORDER BY (quantity_in_stock = 0) ASC, product_name ASC
Beware, however, if quantity_in_stock not indexed, query performance may adversely affect this.
source share