Link to home
Start Free TrialLog in
Avatar of bobdylan75
bobdylan75Flag for Afghanistan

asked on

db2 sql: if A-B <0 then return 0 else return a-b

Hi,
In DB2 sql syntax
how to do the function below?
SELECT Qcode, iif( sum(A)>= sum(B), 0, SUM(B) - SUM(A)) AS QTy
FROM [...] group by Qcode

in other world, how to do the same of IIF function seen that it doesn't exist in db2?
(v5r4m0)

Or is there a function which return number 'A' if it is positive
and Zero if it is negative?
ASKER CERTIFIED SOLUTION
Avatar of bobdylan75
bobdylan75
Flag of Afghanistan 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
Avatar of bobdylan75

ASKER

I found by myself the solution, thank you.