The Question
SQLCRM Marketing Touch Streak Analysis
A marketing team wants to reward highly engaged potential customers. Given a
marketing_touches table (event_id, contact_id, event_type, event_date) and a crm_contacts table (contact_id, email), find the email addresses of all contacts who meet two conditions:
1. They had at least one marketing touch per week for at least three consecutive weeks (weeks are defined as starting on Monday).
2. They have performed at least one touch of type 'trial_request' at any point in their history.
Ensure the solution handles contacts with multiple touches in a single week correctly and accounts for streaks that might cross year boundaries.Snowflake
CTE
Window Function
DENSE_RANK
Gaps and Islands
DATE_TRUNC
DATEADD