IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rexx77

New User


Joined: 14 Apr 2008
Posts: 78
Location: Mysore

PostPosted: Wed Feb 27, 2013 3:30 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 27, 2013 3:55 pm
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: 275
Location: Mumbai

PostPosted: Wed Feb 27, 2013 4:41 pm
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: 78
Location: Mysore

PostPosted: Wed Feb 27, 2013 5:03 pm
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: 275
Location: Mumbai

PostPosted: Wed Feb 27, 2013 5:09 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 27, 2013 5:09 pm
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: 78
Location: Mysore

PostPosted: Wed Feb 27, 2013 5:34 pm
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: 1788
Location: Bloomington, IL

PostPosted: Wed Feb 27, 2013 5:47 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top