Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

12 Experts available now in Live!

Get 1:1 Help Now