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: 74
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: 7315

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: 74
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: 7315

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: 74
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: 1770
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
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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