We can use the if condition in order by clause. See the following query as an example.
It is sorting the products based on the condition : if sale_price > 0 then sort by sale_price other wise sort by pro_price
SELECT `pro_id`,`pro_price`,`sale_price` FROM `product` order by if(sale_price>0, `sale_price`,`pro_price`) desc
It is sorting the products based on the condition : if sale_price > 0 then sort by sale_price other wise sort by pro_price
SELECT `pro_id`,`pro_price`,`sale_price` FROM `product` order by if(sale_price>0, `sale_price`,`pro_price`) desc