MySql sort conditional based on column values
I think this would work - although it's rather obfuscated:

ORDER BY 
    price = 0, 
    LEAST(stock, 100) DESC, 
    price ;


More clearly:

ORDER BY 
    CASE WHEN price &gt; 0 THEN 1 ELSE 2 END, 
    CASE WHEN stock &gt;= 100 THEN 100 ELSE stock END DESC, 
    price ;