Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top