1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
(
SELECT t1.NUM_DDV, t1.NOM_DDV, t1.DOM_VENTE, t1.CA_CUM, t2.CA_CUM1
FROM tmp_dep1 t1
LEFT OUTER JOIN tmp_dep2 t2 ON t2.NOM_DDV = t1.NOM_DDV
AND t2.DOM_VENTE = t1.DOM_VENTE
)
union
(
SELECT t2.NUM_DDV, t2.NOM_DDV, t2.DOM_VENTE, t1.CA_CUM, t2.CA_CUM1
FROM tmp_dep1 t1
RIGHT OUTER JOIN tmp_dep2 t2 ON t2.NOM_DDV = t1.NOM_DDV
AND t2.DOM_VENTE = t1.DOM_VENTE
)
union
(
SELECT tm2.NUM_DDV, t2.NOM_DDV, t2.DOM_VENTE, t2.CA_CUM1, tmp_dep3.CA_AN
FROM tmp_dep2 t2
LEFT OUTER JOIN tmp_dep3 t3 ON t2.NOM_DDV = t3.NOM_DDV
AND t2.DOM_VENTE = t3.DOM_VENTE
)
UNION
(
SELECT t3.NUM_DDV, t3.NOM_DDV, t3.DOM_VENTE, tmp_dep2.CA_CUM1, tmp_dep3.CA_AN
FROM tmp_dep2 t2
RIGHT OUTER JOIN tmp_dep3 t3 ON t2.NOM_DDV = t3.NOM_DDV
AND t2.DOM_VENTE = t3.DOM_VENTE
) |
Partager