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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| 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