UNION SQL UTILIZANDO CAMPOS NUMÉRICOS.
Eu tenho dois select e preciso fazer um Union com os dois porém os registros ficam duplicados ao colocar campos numéricos no select.Â
Select convert(nvarchar,t_dimx),convert(decimal(18,2),t_fdah_1) as t_fdah_1,convert(decimal(18,2),t_fcah_1 )as t_fcah_1
from Tab1
where t_leac =[ô]1121102[ô] and t_year=[ô]2014[ô] and t_dtyp=[ô]3[ô] and t_ptyp=[ô]1[ô] and t_prno=[ô]1[ô]
union
Select convert(nvarchar,t_dimx),0 as t_fdah_1,0 as t_fcah_1Â
from Tab2
where t_leac =[ô]1121102[ô] and t_year=[ô]2014[ô] and t_dtyp=[ô]3[ô]
Resultado:
000040Â Â Â 0.00Â Â Â 0.00
000040Â Â Â 1399082.24Â Â Â 178100.95
0808G Â Â Â 0.00Â Â Â 0.00
0808G Â Â Â 965172.95Â Â Â 13584.72
Alguém sabe me dizer onde estou errando por favor?
Select convert(nvarchar,t_dimx),convert(decimal(18,2),t_fdah_1) as t_fdah_1,convert(decimal(18,2),t_fcah_1 )as t_fcah_1
from Tab1
where t_leac =[ô]1121102[ô] and t_year=[ô]2014[ô] and t_dtyp=[ô]3[ô] and t_ptyp=[ô]1[ô] and t_prno=[ô]1[ô]
union
Select convert(nvarchar,t_dimx),0 as t_fdah_1,0 as t_fcah_1Â
from Tab2
where t_leac =[ô]1121102[ô] and t_year=[ô]2014[ô] and t_dtyp=[ô]3[ô]
Resultado:
000040Â Â Â 0.00Â Â Â 0.00
000040Â Â Â 1399082.24Â Â Â 178100.95
0808G Â Â Â 0.00Â Â Â 0.00
0808G Â Â Â 965172.95Â Â Â 13584.72
Alguém sabe me dizer onde estou errando por favor?
Faça seu login para responder