Solved

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

Posted on 2011-03-11
2
1,687 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

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.

Question has a verified solution.

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

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 (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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