Link to home
Start Free TrialLog in
Avatar of kingjely
kingjelyFlag for Australia

asked on

Mysql if a sum is null make it 0.00


Hi guys, how do i get this string to return 0.00 if it is null

I sum(h.unitsell * h.quantity - h.bulkdiscount,0.00) as YTD,

Thankyou
ASKER CERTIFIED SOLUTION
Avatar of Yuval_Shohat
Yuval_Shohat
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try using IFNULL as following

SELECT IFNULL(0.00,h.unitsell * h.quantity - h.bulkdiscount) AS YTD FROM <tablename>
Avatar of kingjely

ASKER

champion
 Tanks!
or try doing

SELECT IFNULL(0.00,sum(h.unitsell * h.quantity - h.bulkdiscount)) AS YTD FROM <tablename>
Hey sorry kill max i was already done!
SOrry mate, thanks anyways =D
select
case isnull( sum(h.unitsell * h.quantity - h.bulkdiscount,0.00)  )
when 0 then sum(h.unitsell * h.quantity - h.bulkdiscount,0.00)
when 1 then 0.00
end case