1 2 3 4 5 6 7 8 9 10
|
select SIH.SIVTYP_0,ml6220.LANMES_0, ml406.LANMES_0, count(*) as result from RES.SINVOICE SIH
left join RES.BPCUSTOMER BPC on SIH.BPR_0 = BPC.BPCNUM_0
left join RES.SINVOICEV SIV on SIH.NUM_0 = SIV.NUM_0
left join RES.APLSTD ml6220 on (ml6220.LANCHP_0=6220 and ml6220.LAN_0='FRA' and ml6220.LANNUM_0= BPC.YCODIMP_0)
left join RES.APLSTD ml406 on (ml406.LANCHP_0=406 and ml406.LAN_0='FRA' and ml406.LANNUM_0= BPC.INVPER_0)
where SIH.accdat_0 between to_date('20170701','YYYYMMDD') and to_date('20170731','YYYYMMDD') and
BPC.BCGCOD_0 in ('TRD','TRX','TRY') and
SIV.SALFCY_0 in ('WES','CWS','CTS','GTS','GSS','WSS','GDS','CGS')
group by SIH.SIVTYP_0,ml6220.LANMES_0, ml406.LANMES_0 |
Partager