Created
June 23, 2022 08:43
-
-
Save Djourdain/e84e0e42eb146af4d1652a4db0b893f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH FAMILLE_SAUVE AS( | |
SELECT cdfam, MAX(cdmaj) AS cdmaj, MAX(dtsave) | |
FROM ever_famille_sauve | |
WHERE dtsave >= :dateDernierTraitement | |
GROUP BY cdfam | |
) | |
SELECT efs.cdfam as code_famille, | |
f.libfam as libelle_famille, | |
m.id_centre_profit AS centre_profit, | |
efs.cdmaj = 'S' AS a_supprimer | |
FROM FAMILLE_SAUVE efs | |
INNER JOIN famille f | |
ON f.cdfam = efs.cdfam | |
AND f.dtann IS NULL | |
AND f.cdfam IS NOT NULL | |
INNER JOIN mapping_centre_profit_famille m | |
ON m.cdcategfam = f.cdcategfam | |
AND m.id_centre_profit IS NOT NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment