View previous topic :: View next topic
|
Author |
Message |
rexx77
New User
Joined: 14 Apr 2008 Posts: 78 Location: Mysore
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
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 |
|
|
rexx77
New User
Joined: 14 Apr 2008 Posts: 78 Location: Mysore
|
|
|
|
I have tried it already got the below error
Code: |
Arithmetic overflow or other arithmetic exception occurred. SQLSTATE=01519
|
|
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
rexx77
New User
Joined: 14 Apr 2008 Posts: 78 Location: Mysore
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
|