mysql - ORDER BY formula not working correctly -
i've been searching hours trying figure out why order not work correctly on formula:
select *, format(lowpricecompetitor - (-(products.distprice + 0.30) / ((rates.rate + 0.02 + rates.defaultmarkup) - 1)), 2) margin products left join rates on products.mastercategoryid = rates.categoryid order margin
how can mysql correctly order output of formula? should work!
one quick way sort strings numeric values (for example, values returned format()
function, or other expression returns character datatype),
is add 0 expression. mysql perform implicit conversion character numeric:
select format(lpc - (-(p.dp + 0.30) / ((r.rate + 0.02 + r.dm) - 1)), 2) margin t join ... order margin+0 ^^---- quick fix here add 0
Comments
Post a Comment