Skip to content

Commit

Permalink
Merge pull request #2206 from TEAMSchools/contacts-referral
Browse files Browse the repository at this point in the history
add sw referral date to cn view
  • Loading branch information
anthonygwalters authored Nov 21, 2024
2 parents 6bc91e2 + 99313fc commit f283663
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 f283663

Please sign in to comment.