Product Experiments

Case studies, frameworks, and writing samples.

View the Project on GitHub stacynwigwe/product-experiments

Home | πŸ”™ Back to Portfolio β€”

CLASS SQL Framework

Overview

A 5-step, plain-English method I use to turn messy questions into clean, defensible SQL and clear, decision-ready outputs.


Purpose

Make analytics work fast, accurate, and explainable by guiding stakeholders (and myself) through a consistent sequence from question β†’ data β†’ filters β†’ math β†’ output.


The Framework (CLASS)

C β€” Clarify the Question
What exactly are they asking? β€œPer student? Per grade? Per school? Which timeframe? Which subject?”

L β€” Locate the Data
Which table(s)/files contain the fields you need? Identify keys, grain, and joins.

A β€” Apply the Filters
Which rows count? (e.g., Math only, last school year, scores > 70, active students)

S β€” Select the Calculation
What math answers the question? (COUNT, AVG, SUM, % growth, rank, trend)

S β€” Show the Results
How should it be presented? (columns, labels, sort, top/bottom N, grouping)


Quick Checklist (copy/paste before you query)

CLASS SQL Framework

From question to answer β€” fast, accurate, explainable.


Example (K-12 assessment use case)

Ask: β€œWhich elementary schools improved average Math proficiency year-over-year?”

**SQL sketch:**

```sql
WITH base AS (
  SELECT
    s.school_id,
    sy.year,
    AVG(CASE WHEN a.score >= 70 THEN 1.0 ELSE 0.0 END) AS proficiency_rate
  FROM assessments a
  JOIN students st ON st.student_id = a.student_id
  JOIN schools s  ON s.school_id = st.school_id
  JOIN school_years sy ON sy.id = a.school_year_id
  WHERE a.subject = 'Math'
    AND st.grade IN ('K','1','2','3','4','5')
    AND sy.year IN (2023, 2024)
  GROUP BY s.school_id, sy.year
),
pivot AS (
  SELECT
    b2023.school_id,
    b2023.proficiency_rate AS rate_2023,
    b2024.proficiency_rate AS rate_2024,
    (b2024.proficiency_rate - b2023.proficiency_rate) AS delta
  FROM base b2023
  JOIN base b2024
    ON b2023.school_id = b2024.school_id
   AND b2023.year = 2023 AND b2024.year = 2024
)
SELECT sc.school_name, rate_2023, rate_2024, delta
FROM pivot p
JOIN schools sc ON sc.school_id = p.school_id
ORDER BY delta DESC
LIMIT 10;
```