1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| SELECT code_a, Date_mouvement, Q_entree, Prix_entree, Q_sortie, Prix_sortie
FROM (
SELECT a.code_a, e.date_e AS Date_mouvement
COALESCE(e.quantite_e, 0) AS Q_entree, e.prix_a AS Prix_entree,
NULL AS Q_sortie, NULL AS Prix_sortie
FROM article a
INNER JOIN entree_s e ON a.n_art = e.n_art
UNION
SELECT a.code_a, e.date_e AS Date_mouvement
NULL AS Q_entree, NULL AS Prix_entree,
COALESCE(s.quantite_s,0) AS Q_sortie, s.prix_u AS Prix_sortie
FROM article a
INNER JOIN sortie_s s ON a.n_art = s.n_art
) tmp
WHERE tmp.n_art = 800
AND tmp.Date_mouvement BETWEEN '2008-01-01' AND '2009/01/21' |
Partager