jsbx
asked on
Join 2 tables (MS Sql 2005)
Hello, I'm sure this is pretty easy, but I can't find a way to do it.
Thank you,
band.
TABLE A:
CODIGO VENTA COMPRA
10 100 0
20 100 0
30 100 0
TABLE B:
CODIGO VENTA COMPRA
40 0 100
20 0 100
50 0 100
I need to get this in just one select:
CODIGO VENTA COMPRA
10 100 0
20 100 100
30 100 0
40 0 100
50 0 100
Thank you,
band.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked like a charm.
Thanks Sean also, but I got errors on that code.
Thanks Sean also, but I got errors on that code.
SELECT CODIGO,VENTA,COMPRA
FROM TableA
GROUP BY CODIGO
UNION ALL
SELECT CODIGO,VENTA,COMPRA
FROM TableB
GROUP BY CODIGO