1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
select NumBon ,c_produit ,Date_bon ,D_Client, QTE , TP from
( select L.NumBon ,D.c_produit ,L.Date_bon ,C.D_Client, cast( qte*-1 as dec(15,2) )AS QTE , cast( qte*3 as dec(15,2)) AS TP
from bon_livr L, D_livr d,Client C
where (L.valide ='OUI')and(L.numbon=d.numbon)and((l.RESERVATION= 'NON')or(RESERVATION is Null))and(d.c_produit =:P1)
and(C.C_client = L.Client)and(l.date_bon >=:D1)and(l.date_bon <=:D2)and(l.codemagasin =:m)
union all
select L.NumBon ,D.c_produit ,L.Date_bon ,C.D_Client , cast( D.qte*-1 as dec(15,2) )AS QTE , cast( D.qte*3 as dec(15,2)) AS TP
from bon_livr L, D_ENSL d,Client C
where (L.valide ='OUI')and(L.numbon=d.NUMPIECE)and((l.RESERVATION= 'NON')or(RESERVATION is Null))and(d.c_produit =:P1)
and(C.C_client = L.Client)and(l.date_bon >=:D1)and(l.date_bon <=:D2)and(l.codemagasin =:m)
union ALL
select L.NumBon ,D.c_produit ,L.Date_bon ,C.D_Client , cast( D.qte*1 as dec(15,2) )AS QTE , cast( D.qte*2 as dec(15,2))AS TP
from bon_ret L, d_ret d,Client C
where (L.valide ='OUI')and(L.numbon=d.numbon)and(D.c_produit=:P1)
and(C.C_client = L.Client)and(l.date_bon >=:D1)and(l.date_bon <=:D2)and(l.codemagasin =:m)
)
ORDER BY DATE_BON, qte DESCENDING |
Partager