Files
school_compare/pipeline/transform/macros/parse_ofsted_grade.sql

14 lines
600 B
MySQL
Raw Normal View History

-- Macro: Parse Ofsted grade from various text/numeric representations
{% macro parse_ofsted_grade(column) %}
case
when {{ column }}::text in ('1', 'Outstanding') then 1
when {{ column }}::text in ('2', 'Good') then 2
when {{ column }}::text in ('3', 'Requires improvement', 'Requires Improvement', 'Satisfactory') then 3
when {{ column }}::text in ('4', 'Inadequate') then 4
when {{ column }}::text in ('9', 'SWK', 'Serious Weaknesses') then 4
when {{ column }}::text in ('SM', 'Special Measures') then 4
else null
end
{% endmacro %}