SELECT
1
, NULL, NULL
, CAST(acy.S3_COL05N AS int), acy.S3_COUNCIL, acy.S3_FAMILY, acy.S3_SUB_FAMILY, acy.S3_DESTINATION_REGION, acy.S3_DESTINATION_REGIONAL_UNIT, acy.S3_DESTINATION_COUNTRY, acy.S3_DESTINATION_UNIT
, 0
, acy.S3_PROJECT_NUMBER, acy.S3_ACTIVITY_NUMBER, acy.S3_ACTIVITY_NAME, acy.S3_SYNERGY_FLAG, acy.S3_BUSINESS_GROUP, acy.S3_BUSINESS_DIVISION, acy.S3_BUSINESS_UNIT,
acy.S3_SOURCING_RESP, acy.S3_ACTIVITY_TYPE, acy.S3_ACTIVITY_DESCRIPTION, acy.S3_CURRENCY
, CASE WHEN acy.S3_ACTIVITY_STATUS = 'R' THEN 'R' ELSE 'NR' END, acy.S3_REPORTING_STATUS
, acy.S3_ACTIVITY_OWNER, acy.S3_ACTIVITY_COMMENT, acy.S3_CHANGE_COMMENT
, 1
FROM S3_ACTIVITY acy
WHERE acy.S3_CRULE_UPDATE_FLAG = 1
AND acy.S3_LATEST_ACTIVITY_FLAG = 'Y'
AND CAST(acy.S3_COL05N AS int) >= CAST(acy.S3_YEAR_ZERO AS int)
AND CAST(acy.S3_COL05N AS int) <= CAST(acy.S3_YEAR_ZERO AS int) + 2
AND NOT EXISTS (SELECT 0 FROM S3_ACTION WHERE S3_COL05N = 1 AND S3_ACTIVITY_NUMBER = acy.S3_ACTIVITY_NUMBER)
AND (IsNull(acy.S3_AXIS_VOLUME_LOC,0) > 0 OR IsNull(acy.S3_AXIS_SAVING_LOC,0) > 0);
Partager