This is query :
SELECT f.matName
,f.matCode
,COALESCE(SUM(`INPUT`), 0) - COALESCE(SUM(`OUTPUT`), 0) AS `INVENTORY`
,f.unitPrice
,(COALESCE(SUM(`INPUT`), 0) - COALESCE(SUM(`OUTPUT`), 0))
* (COALESCE(unitPrice, 0)) AS `RialiInventory`
FROM (
---subquery---
) AS `f`
GROUP BY f.matName
,f.matCode
In above query if (INVENTORY) value be less than “0” , then (RialiInventory) will be a negative value but I need to return “0” value for those (RialiInventory) values that their (INVENTORY) values are less than “0” .
Note : I don`t want miss any (INVENTORY) value .
thanks in advance