Last active
February 8, 2022 09:19
-
-
Save fourgeotf/bb2884e392899b4ac8af6539f3463b8c to your computer and use it in GitHub Desktop.
[Mise en sommeil des clients créés depuis plus de 5 ans sans documents] #loisiralp #sql
This file contains 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
--SELECT | |
-- ct.CT_Num | |
-- ,ct.cbCreation | |
-- ,ct.CT_NumPayeur | |
-- ,do.Max_DO_Date | |
-- ,ct.CT_Sommeil | |
UPDATE ct SET ct.CT_Sommeil = 1 | |
FROM F_COMPTET ct | |
LEFT JOIN (SELECT do.DO_Tiers, MAX(do.DO_Date) AS Max_DO_Date FROM F_DOCENTETE do WHERE do.DO_Domaine = 0 GROUP BY do.DO_Tiers) AS do ON do.DO_Tiers = ct.CT_NumPayeur | |
WHERE YEAR(ct.cbCreation) <= 2017 | |
AND ct.CT_Type = 0 | |
AND ct.CT_Sommeil = 0 | |
AND Max_DO_Date IS NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment