How to multiplied by zero and non zero columns in mysql?
by Jayanthi[ Edit ] 2013-01-28 11:37:24
How to multiplied by zero and non zero columns in mysql
The quantity field is less than '1',it taken quantity= 1.
SELECT itemname,amount,quantity,(amount*(CASE WHEN quantity <=0
THEN 1 ELSE quantity
END ) ) as total from your_tablename
output
itemname | amount | quantity | total |
soap | 40.00 | 1 | 40.00 |
oil | 55.00 | 0 | 55.00 |
powder | 60.00 | 2 | 120.00 |