1 2 3 4 5 6 7 8 9 10 11 12 13 14
| SELECT A.DTNUMEXE, A.DTMOIEXE, A.DTANNQIT, A.DTMOIQIT, A.DTCODBRC, A.DTSERQIT, A.DTPLCQTC,A.DTCATPOL, A.DTCODRSQ, A.DTNATRSQ, A.DTCODPRO, A.DTTYPQIT, A.DTLIBTYP, A.DTCODETA,
A.DTLIBETA, A.DTCODAGC, A.DTNUMCLT, A.DTNATCLT, A.DTJJDVAL, A.DTMMDVAL, A.DTAADVAL,A.DTJJFVAL, A.DTMMFVAL, A.DTAAFVAL, A.DTCODART, A.DTCODGRN, A.DTPRMNET, A.DTMNTACC,
A.DTJJEMIS, A.DTMMEMIS, A.DTAAEMIS, CASE WHEN A.DTNUMCLT >= 50000 AND A.DTNUMCLT <= 100000 THEN 'OUI' ELSE 'NON' END DTCLTIMP,
CASE UPPER(A.DTPLCEXO) WHEN 'O' THEN 'OUI' WHEN 'N' THEN 'NON' END DTEXOTAX, A.DTMNTCOM ,
(SELECT X.VGCPTPTN FROM AUTOPRD.AUVCLGRPP0 AS X where (X.VGNUMPLC = A.DTPLCQTC ) AND (X.VGCODGRN= A.DTCODGRN)
AND (X.VGJJOCCU * 1000000 + X.VGMMOCCU * 100000000 + X.VGAAOCCU * 10000000000 + X.VGNUMAVT = (SELECT MAX(X.VGJJOCCU * 1000000 + X.VGMMOCCU * 100000000 + X.VGAAOCCU * 10000000000 + X.VGNUMAVT ) AS
DATEOCC FROM AUTOPRD.AUVCLGRPP0
WHERE (X.VGMMOCCU * 100000000 + X.VGAAOCCU * 10000000000 <= (A.DTAADVAL * 10000 + A.DTMMDVAL * 100 + A.DTJJDVAL)*1000000 ) AND (X.VGNUMPLC =A.DTPLCQTC) AND (X.VGCODGRN= A.DTCODGRN))))
FROM TRANSFERT.DTQTTNCPP1 AS A
WHERE (A.DTCODBRC = 1) AND (A.DTCODGRN>0) AND (DTNUMEXE =2020) |
Partager