Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1749
  • Last Modified:

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?
0
bobdylan75
Asked:
bobdylan75
  • 2
1 Solution
 
bobdylan75Author Commented:
CASE (CONDITION) THEN (VALUE) ELSE (VALUE) END
0
 
bobdylan75Author Commented:
I found by myself the solution, thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now