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

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -