Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
help with syntax for using if inside sum

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
jagjit

New User


Joined: 28 Dec 2006
Posts: 18
Location: india

PostPosted: Tue Jun 05, 2007 7:42 pm    Post subject: help with syntax for using if inside sum
Reply with quote

SELECT SUM (IF CASE_PASTDUE > 0
SET CASE_PASTDUE TO CASE_PASTDUE
ELSE SET 0 TO CASE_PASTDUE)

FROM DB2TEST.SPLIT_DETAIL
WHERE SPLIT_TRANS_ID = 10
AND SPLIT_LEVEL = 22;
Back to top
View user's profile Send private message

muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Tue Jun 05, 2007 8:42 pm    Post subject: Re: help with syntax for using if inside sum
Reply with quote

I am not clear of your requirement but seeing the sql why can't the CASE_PASTDUE be used with the WHERE clause? icon_confused.gif

Anyway for SUM syntax is,
Select SUM (column name) AS < variable>
from <table name>
Where <condition>
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jun 05, 2007 8:53 pm    Post subject: Re: help with syntax for using if inside sum
Reply with quote

jagjit wrote:
SELECT SUM (IF CASE_PASTDUE > 0
SET CASE_PASTDUE TO CASE_PASTDUE
ELSE SET 0 TO CASE_PASTDUE)

FROM DB2TEST.SPLIT_DETAIL
WHERE SPLIT_TRANS_ID = 10
AND SPLIT_LEVEL = 22;


Look up the format for the CASE statement in the sql manual.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sending email from jcl using the mail... niloyarp JCL & VSAM 5 Tue Oct 10, 2017 12:32 pm
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm
No new posts NDM syntax checking without actually ... GAPX1 All Other Mainframe Topics 0 Wed Jun 07, 2017 2:36 am
No new posts FINDREP Syntax Error seahawk789 DFSORT/ICETOOL 4 Thu Mar 09, 2017 10:11 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us