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
 

 

Max function in DB2

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

New User


Joined: 12 Apr 2008
Posts: 36
Location: NOIDA

PostPosted: Mon Dec 21, 2009 11:27 am    Post subject: Max function in DB2
Reply with quote

Hi ,

I have requirement like in the below query.
SELECT MAX(ACDFCPNN) FROM TE.UTE01011_ACFTDEFCT
WHERE ACFTABB = WS_ACFTABB
INTO :WS_ACDFCPNN;

I tried to run this query in QMF when the value passed in WS_ACFTABB is not available in table then the query is returning Null value as '-' .
Now then I have rquirement to move Zero to the host variable WS_ACDFCPNN when the query returns null value ie '-'.
Can somebody assist that how to handle this.

Thanks,
Chandan Kapoor
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon Dec 21, 2009 12:03 pm    Post subject:
Reply with quote

Hello Chandan,

Please try below query:

Code:
SELECT COALESCE(MAX(ACDFCPNN),0) FROM TE.UTE01011_ACFTDEFCT
WHERE ACFTABB = WS_ACFTABB
INTO :WS_ACDFCPNN;
Back to top
View user's profile Send private message
CHANDAN KAPOOR

New User


Joined: 12 Apr 2008
Posts: 36
Location: NOIDA

PostPosted: Mon Dec 21, 2009 12:21 pm    Post subject: Reply to: Max function in DB2
Reply with quote

Thanks , Ekta for your quick reply.
Back to top
View user's profile Send private message
tamal_babu

New User


Joined: 06 Feb 2006
Posts: 17
Location: Kolkata

PostPosted: Mon Dec 21, 2009 6:46 pm    Post subject: Reply to: Max function in DB2
Reply with quote

u can use VALUE function as well...
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
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm


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