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
| select a.ref_br
, a.ref_article
, a.qte as qtebonne
, b.qte as qtemauvaise
from (
SELECT REF_BR
, REF_ARTICLE
, SUM (QTE_ARTICLE) AS QTE
FROM T_COLIS_BR_LIGNE
WHERE REF_BR ='REC-A8012-00057'
AND ETAT='BONNE'
AND ACTIVITE ='RECEPTION'
GROUP BY REF_BR
, REF_ARTICLE
) a
left join (
SELECT REF_BR
, REF_ARTICLE
, SUM (QTE_ARTICLE) AS QTE
FROM T_COLIS_BR_LIGNE
WHERE REF_BR ='REC-A8012-00057'
AND ETAT='MAUVAISE'
AND ACTIVITE ='RECEPTION'
GROUP BY REF_BR
, REF_ARTICLE
) b on a.ref_br = b.ref_br
and a.ref_article = b.ref_article |
Partager