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
 

 

How to Sum up coulmns of 2 diff datatypes in db2select query

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

New User


Joined: 14 Apr 2008
Posts: 73
Location: Mysore

PostPosted: Wed Feb 27, 2013 3:30 pm    Post subject: How to Sum up coulmns of 2 diff datatypes in db2select query
Reply with quote

Code:
Column A | Column B | Column C
XXXX     | 109      | 00.98

I need a db2 select query to fetch the result like below
Result:
Code:
Field1   | Field2
XXXXX    | 109.98

Merging column B and C but both are having below data types
DECIMAL(15,0)
DECIMAL(11,11)
Please help me out in finding the solution

Code'd and aligned
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Feb 27, 2013 3:55 pm    Post subject: Reply to: How to Sum up coulmns of 2 diff datatypes in db2se
Reply with quote

Please use the Code tags, which preserve spacing in a proportional font, and the Preview button so that you know that the post is correct before Submit.
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Wed Feb 27, 2013 4:41 pm    Post subject:
Reply with quote

Hi,

What you have tried so far?

Try sql query

Code:
Select Column A ,
(Column B + Column c)
From Table


Regards,
Chandan
Back to top
View user's profile Send private message
rexx77

New User


Joined: 14 Apr 2008
Posts: 73
Location: Mysore

PostPosted: Wed Feb 27, 2013 5:03 pm    Post subject:
Reply with quote

I have tried it already got the below error

Code:
 Arithmetic overflow or other arithmetic exception occurred.  SQLSTATE=01519
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Wed Feb 27, 2013 5:09 pm    Post subject:
Reply with quote

I tried this woith spufi and its working fine for me

if its giving arithmatic overflow for you then it must be something to deal with host variable you are using.

Is there any possibilty of having Null values in these columns?

It will be great if you paste the query and host variable you are using

Regards,
Chandan
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Feb 27, 2013 5:09 pm    Post subject: Reply to: How to Sum up coulmns of 2 diff datatypes in db2se
Reply with quote

Well, you need to tell us what you have tried, and what happened.

What you are saying then is how to add something with no decimal places to something with only decimal places and have a result field which accurately reflects both the fields.
Back to top
View user's profile Send private message
rexx77

New User


Joined: 14 Apr 2008
Posts: 73
Location: Mysore

PostPosted: Wed Feb 27, 2013 5:34 pm    Post subject:
Reply with quote

Yes Bil,
My probelm is Column B is having datatype of DECIMAL(15,0) means only have values like 11,13,44 and Column C is having datatype as Decimal(11,11) means only decimal values .23424, .6668, .889
I want to have result as a combination of Column B and C like
11.2322 kind of merging
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed Feb 27, 2013 5:47 pm    Post subject:
Reply with quote

rexx77 wrote:
I have tried it already got the below error

Code:
 Arithmetic overflow or other arithmetic exception occurred.  SQLSTATE=01519

Is that not a warning, rather than an error? Did you get a positive or negative SQLCODE?

Your result will have, I believe, a type, precision, and scale of DECIMAL(26,11). Is this permissible in whatever version of DB2 you are running?
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. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts SQL Query optimization. arunsoods DB2 12 Sun Sep 04, 2016 6:27 am
No new posts Query on BLSR Nileshkul JCL & VSAM 2 Sat Aug 13, 2016 5:18 am


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