21 lines
987 B
SQL
21 lines
987 B
SQL
-- Macro: Parse an Ofsted ungraded (Section 8) inspection outcome into a grade.
|
|||
|
|
--
|
||
|
|
-- Ungraded inspections do not assign a fresh grade; the outcome is free text
|
||
|
|
-- describing whether the school kept its previous judgement, e.g.
|
||
|
|
-- "School remains Good", "School remains Good (Concerns) - S5 Next",
|
||
|
|
-- "School remains Outstanding", "School remains Outstanding (Concerns) - S5 Next".
|
||
|
|
-- These are the only Good/Outstanding signal we can recover, so we match on the
|
||
|
|
-- "remains <grade>" phrase (tolerant of any trailing qualifier).
|
||
|
|
--
|
||
|
|
-- Outcomes that don't establish a Good/Outstanding status — "Standards
|
||
|
|
-- maintained", "Improved significantly", "Some aspects not as strong" — map to
|
||
|
|
-- null. Grades align with parse_ofsted_grade (1 = Outstanding, 2 = Good).
|
||
|
|
|
||
|
|
{% macro parse_ungraded_outcome(column) %}
|
||
|
|
case
|
||
|
|
when {{ column }} ilike '%remains Outstanding%' then 1
|
||
|
|
when {{ column }} ilike '%remains Good%' then 2
|
||
|
|
else null
|
||
|
|
end
|
||
|
|
{% endmacro %}
|