How to multiplied by zero and non zero columns in mysql?

by Jayanthi 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





itemnameamountquantitytotal
soap40.00140.00
oil55.00055.00
powder60.002120.00
1042
like
0
dislike
0
mail
flag

You must LOGIN to add comments