Use PHP and Mysql.
Fields in my table (product) are id, full_price, sell_price, etc.
How can I SELECT products ORDER BY discount DESC, where discount = (full_price-sell_price) * 100 / full_price? I try to use this, but it doesn’t work:
SELECT *
FROM product
WHERE full_price > 0
ORDER BY (discount = (full_price - sell_price) * 100 / full_price)
LIMIT 10
If you want the discount to be a column in the result set too, do it like this: