-- Mart: KS4 performance fact table — one row per URN per year
-- Includes predecessor data via lineage resolution

select
    current_urn as urn,
    source_urn,
    year,
    total_pupils,
    eligible_pupils,
    prior_attainment_avg,

    -- Attainment 8
    attainment_8_score,

    -- Progress 8
    progress_8_score,
    progress_8_lower_ci,
    progress_8_upper_ci,
    progress_8_banding,
    attainment_8_disadvantage_gap,
    progress_8_disadvantage_gap,
    progress_8_english,
    progress_8_maths,
    progress_8_ebacc,
    progress_8_open,

    -- English & Maths
    english_maths_strong_pass_pct,
    english_maths_standard_pass_pct,

    -- EBacc
    ebacc_entry_pct,
    ebacc_strong_pass_pct,
    ebacc_standard_pass_pct,
    ebacc_avg_score,

    -- GCSE
    gcse_grade_91_pct,

    -- Context
    sen_pct,
    sen_ehcp_pct,
    sen_support_pct

from {{ ref('int_ks4_with_lineage') }}
