tags:

views:

258

answers:

2

I have built a query which contains UNION ALL, but the two parts of it have not the same data type. I mean, i have to display one column but the format of the two columns, from where i get the data have differences. So, if i get an example :

select a,b
from c
union all
select d,b
from e

a and d are numbers, but they have different format. It means that a's length is 15 and b's length is 13. There are no digits after the floating point. Using digits, varchar, integer and decimal didn't work. I always get the message : Data conversion or data mapping error. How can i convert these fields in the same format?

+1  A: 

I've no DB2 experience but can't you just cast 'a' & 'd' to the same types. That are large enough to handle both formats, obviously.

Matt Lacey
Thank you, for your answer!
Jolma
A: 

I have used the cast function to convert the columns type into the same type(varchar with a large length).So i used union without problems. When i needed their original type, back again, i used the same cast function(this time i converted the values into float), and i got the result i wanted.

Jolma