mercredi 23 décembre 2015

UNION producing a column of maximum precision of two columns

If you combine columns of different yet convertible data types, the result of the UNION will produce a column data type equal to the maximum precision of the two columns.

create table tab1 (col1 decimal (5,2)) create table tab2 (col2 int)

insert into tab1 values (11.5) insert into tab2 values(11)

select col1 from tab1 union select col2 from tab2

RESULT:

11.00 11.50

BUT i should get result as

RESULT:

11 11.50

Is there a way to achieve this?

In reality the queries are not this simple.

Aucun commentaire:

Enregistrer un commentaire