From 497f6911c9ac60749c8712c18f5450648cdaf812 Mon Sep 17 00:00:00 2001 From: Matthew Trew Date: Thu, 25 Sep 2025 10:43:42 +0100 Subject: [PATCH] Add pre-filtered table for state schools --- .../db_scripts/create_analysis_transforms.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/resources/db_scripts/create_analysis_transforms.sql b/src/main/resources/db_scripts/create_analysis_transforms.sql index 0569df26ff..cfa6bd07d3 100644 --- a/src/main/resources/db_scripts/create_analysis_transforms.sql +++ b/src/main/resources/db_scripts/create_analysis_transforms.sql @@ -202,4 +202,14 @@ CREATE TABLE anonymous.teacher_engagement_v2_events AS OR event_type = 'VIEW_HINT' AND event_details ->> 'hintIndex' = '0' ) UNION - (SELECT user_id, timestamp from anonymous.workshop_join_events); \ No newline at end of file + (SELECT user_id, timestamp from anonymous.workshop_join_events); + +CREATE TABLE anonymous.england_scotland_state_schools_v2 AS + SELECT * + FROM anonymous.schools_2024 as schools + WHERE + -- Scottish school info comes from schools_2024 - we need to filter for LA-run schools. + (schools.school_type_group = 'Local Authority' AND schools.data_source IN ('GOVERNMENT_SCO')) + -- For English schools, we have a pre-prepared table of state schools. Additionally, we want to include Colleges. + OR urn IN (SELECT urn FROM anonymous.schools_2024_english_state) + OR schools.school_type_group = 'Colleges' \ No newline at end of file