Solved

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

Posted on 2011-03-11
2
1,677 Views
Last Modified: 2012-08-13
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
Comment
Question by:bobdylan75
  • 2
2 Comments
 

Accepted Solution

by:
bobdylan75 earned 0 total points
ID: 35107630
CASE (CONDITION) THEN (VALUE) ELSE (VALUE) END
0
 

Author Closing Comment

by:bobdylan75
ID: 35107631
I found by myself the solution, thank you.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now