我想在特定条件下按折扣对产品进行排序
ORDER BY
CASE WHEN @OrderBy = 0
THEN table.id END ASC,
CASE WHEN @Orderby = 2
THEN table.id END ASC,
我想做类似下面的事情,因为表中没有折扣列
CASE WHEN @OrderBy = 4
THEN (100-((table.price/table.oldprice)*100) as discount END ASC
但它会引发错误 - 我如何按折扣排序?