Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am
No new posts Syntax for running batch history repo... polymathtarun CA Products 1 Tue Jun 21, 2016 1:51 pm
No new posts Syntax to check the first 4 digits of... kshirabdhi DFSORT/ICETOOL 10 Tue May 03, 2016 12:21 pm
No new posts Syntax to create new tableBASE library Sumeendar IBM Tools 1 Tue Sep 15, 2015 6:25 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us