php - MYSQL select, set all negative values to zero -
let assume have mysql table called "test" in table have 2 columns "a", "b". want result of a-b, each row result negative, want set zero.
so can write : select test.a - test.b myresult
but don't know how set myresult 0 when myresult negative number. please
select case when test.a - test.b >= 0 test.a - test.b else 0 end myresult test;
Comments
Post a Comment