← All projects
Tavern Group: SQL-Powered Welcome Journey
The data behind a welcome journey: SQL that decides who is eligible, feeds Journey Builder every day and tracks coupon redemption for the reminder email.
01 · The result
What it produced
02 · How I built it
The logic, in plain English
- The staging query qualifies members: signed up in the last 24 hours, opted in, aged 21+ and registered at an active venue.
- Excludes banned members, staff email addresses and anyone already in the journey, using
EXISTSandNOT EXISTS. - Generates a WELCOME-{MemberID} coupon code and a HasRedeemed flag from the Transactions Data Extension.
- The journey's decision split reads that flag, so the reminder only goes to people who still need it.
Built and tested in an SFMC sandbox. The journey was configured but not activated for live sending.
03 · Under the hood
Who gets into the journey
A short excerpt. The full code and the brief's requirements are on GitHub.
SQLWelcome_Journey_Staging
FROM [Signups] S /* HAVE OPTED INTO EMAILS */ WHERE S.EmailOptIn = 1 /* HAVE SIGNED UP WITHIN LAST 24 HOURS */ AND S.SignedUpDate >= DATEADD(D, -1, GETDATE()) /* ARE 21 YEARS OR ABOVE */ AND S.DOB <= DATEADD(YEAR, -21, GETDATE()) /* MUST BE SIGNED UP TO AN ACTIVE VENUE */ AND EXISTS (SELECT 1 FROM [Venue] V WHERE S.VenueID = V.VenueID AND V.IsVenueActive = 'TRUE') /* NOT IN THE EXCLUDED DE, NOT STAFF */ AND NOT EXISTS (SELECT 1 FROM [ExcludedMembers] Exc WHERE S.Email = Exc.Email) AND S.Email NOT LIKE '%@taverngroupstaff.com' /* NOT ALREADY ADDED TO JOURNEY */ AND NOT EXISTS (SELECT 1 FROM [Welcome_Journey_Entry] E WHERE S.MemberID = E.MemberID)


