I have two databases and in each one two tables from which I need to add a field, but unified.
I did the following query
but it separates the results of each table and I need both:
Select sum(Cantidades) as Entregado
From BD1..Facturas
Where Codigo ='00050'
Union All
Select sum(Cantidades) as Entregado
From BD2..FacturasA
Where Codigo ='00050'
Result
Delivered
- 5773
- 90
Expected result
Delivered: 5863
you must porner inside a derived table like this: