diff --git a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__kfwd_spi.sql b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__kfwd_spi.sql index 5c2deba26e..4d2d17aa47 100644 --- a/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__kfwd_spi.sql +++ b/src/dbt/kipptaf/models/extracts/tableau/rpt_tableau__kfwd_spi.sql @@ -195,5 +195,8 @@ select then '<2.00' end as hs_gpa_bands, from {{ ref("int_kippadb__roster") }} as r -left join {{ ref("base_kippadb__application") }} as a on r.contact_id = a.applicant +left join + {{ ref("base_kippadb__application") }} as a + on r.contact_id = a.applicant + and a.rn_application_school = 1 left join {{ ref("int_kippadb__enrollment_pivot") }} as ei on r.contact_id = ei.student diff --git a/src/dbt/kipptaf/models/kippadb/base/base_kippadb__application.sql b/src/dbt/kipptaf/models/kippadb/base/base_kippadb__application.sql index 921643258a..10580e74a2 100644 --- a/src/dbt/kipptaf/models/kippadb/base/base_kippadb__application.sql +++ b/src/dbt/kipptaf/models/kippadb/base/base_kippadb__application.sql @@ -120,4 +120,8 @@ select if( is_submitted and is_certificate and is_accepted, true, false ) as is_accepted_certificate, + row_number() over ( + partition by applicant, school + order by is_matriculated desc, is_accepted desc, is_submitted desc + ) as rn_application_school, from app_acct