diff --git a/pipeline/transform/models/marts/dim_school.sql b/pipeline/transform/models/marts/dim_school.sql index 9dead72..014acbe 100644 --- a/pipeline/transform/models/marts/dim_school.sql +++ b/pipeline/transform/models/marts/dim_school.sql @@ -14,7 +14,14 @@ select s.urn, s.local_authority_code * 1000 + s.establishment_number as laestab, s.school_name, - s.phase, + case + when s.phase is not null and s.phase != 'Not applicable' then s.phase + when s.statutory_high_age is not null and s.statutory_high_age <= 11 then 'Primary' + when s.statutory_low_age is not null and s.statutory_low_age >= 11 then 'Secondary' + when s.statutory_low_age is not null and s.statutory_high_age is not null + and s.statutory_low_age < 11 and s.statutory_high_age > 11 then 'All-through' + else s.phase + end as phase, s.school_type, s.academy_trust_name, s.academy_trust_uid,