Stage 1 — Ingestion and eligibility
SQL/ERP extraction enforcing business eligibility rules and deduplication per survey type.
-- Eligibility with 90-day quarantine (synthetic)
SELECT
'2026-Q4-SAMPLE' AS cohort_id,
acc.synthetic_member_key,
evt.survey_type
FROM dw_staging.sample_interactions AS evt
JOIN dw_core.sample_accounts AS acc ON acc.account_ref = evt.account_ref
WHERE acc.opt_out_flag = FALSE;View full code
-- Synthetic example: no real institution schema or PII
WITH eligible_accounts AS (
SELECT
acc.synthetic_member_key,
evt.interaction_channel,
evt.event_timestamp,
ROW_NUMBER() OVER (
PARTITION BY acc.synthetic_member_key, evt.survey_type
ORDER BY evt.event_timestamp DESC
) AS rn
FROM dw_staging.sample_interactions AS evt
INNER JOIN dw_core.sample_accounts AS acc
ON acc.account_ref = evt.account_ref
LEFT JOIN integration.qualtrics_dispatch_log AS log
ON log.synthetic_member_key = acc.synthetic_member_key
AND log.survey_type = evt.survey_type
AND log.dispatched_at >= CURRENT_TIMESTAMP - INTERVAL '90 days'
WHERE evt.survey_type IN ('NPS', 'CSAT', 'RM_EVAL')
AND acc.opt_out_flag = FALSE
AND log.dispatch_id IS NULL
)
SELECT
'2026-Q4-SAMPLE' AS cohort_id,
synthetic_member_key,
interaction_channel
FROM eligible_accounts
WHERE rn = 1;