Skip to content

Commit

Permalink
add sw referral date to cn view
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Walters committed Nov 21, 2024
1 parent 6bc91e2 commit 99313fc
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
with
sw_referral as (
select
contact,
academic_year,
date,

row_number() over (
partition by contact, academic_year order by date desc
) as rn_referral,
from {{ ref("stg_kippadb__contact_note") }}
where subject in ('SW REM Referral', 'SW Teammate Referral', 'SW Self Referral')
)

select
ktc.contact_id as sf_contact_id,
ktc.first_name,
Expand All @@ -22,5 +36,12 @@ select
cn.status,
cn.type,
cn.academic_year,

sw.date as referral_date,
from {{ ref("int_kippadb__roster") }} as ktc
inner join {{ ref("stg_kippadb__contact_note") }} as cn on ktc.contact_id = cn.contact
left join
sw_referral as sw
on cn.contact = sw.contact
and cn.academic_year = sw.academic_year
and sw.rn_referral = 1

0 comments on commit 99313fc

Please sign in to comment.