One row per score out of 100. The same data is built into the SQL sandbox as three linked tables (students, courses, scores). All names are made up.
Column | Type | Example | Meaning |
|---|---|---|---|
student | text | Mia Becker | The student's name; each name appears once per course taken |
class | text | 10a | The student's class: 10a or 10b |
course | text | Mathematics | Mathematics, Computer Science, English or Biology |
teacher | text | Ms Novak | The course teacher; one teacher per course |
score | number | 92 | Test score from 0 to 100 |
The file is comma-separated, with a header row and UTF-8 text. It has no empty cells. Opened in a spreadsheet, the columns are A (student) to E (score), and the data sits in rows 2 to 24.
Not every student takes every course. Eight students and four courses would make 32 rows, but there are 23: each student has between two and four scores. Keep that in mind when you compare students.
Facts to check against
8 students in two classes, 4 courses, 23 scores.
Average by class: 10a 85.3, 10b 72.5 (one decimal).
Highest average course: Computer Science, 82.5.
Ten tasks
Spreadsheet formulas below use semicolons between arguments; some language settings use commas instead. The SQL works in the SQL Query Playground after loading the CSV there, where the table is called data.
How many students, courses and scores are there? Why not 32 scores?
What is the average of all 23 scores? What is the median?
What is the average score of each class?
What is the average score of each course?
For each course, find the lowest and highest score and the range. Which course has the widest spread?
Which student has the highest average, and which the lowest?
List every score of 90 or more.
Make a pivot table of average score by course and class. In which course is the gap between the classes largest?
Work out the average of the four student averages in 10a. Why is it different from the class average in task 3?
Which students have at least one score above the overall average?
Solutions
All answers were calculated from the file and checked in SQLite and in the playground. Averages are rounded to one decimal unless stated.
1. 8 students, 4 courses, 23 scores. Each student takes two to four courses, so 9 of the 32 possible combinations are missing.
SELECT COUNT(DISTINCT student) AS students, COUNT(DISTINCT course) AS courses, COUNT(*) AS scores FROM data2. Average 79.1 (79.13 with two decimals), median 81. Spreadsheet: =AVERAGE(E2:E24) and =MEDIAN(E2:E24).
3. 10a: 85.3 from 12 scores. 10b: 72.5 from 11 scores.
SELECT class, COUNT(*) AS scores, ROUND(AVG(score), 1) AS average FROM data GROUP BY classSpreadsheet: =ROUND(AVERAGEIFS(E2:E24; B2:B24; "10a"); 1).
4. Computer Science 82.5, English 78.2, Mathematics 77.8, Biology 77.8. With two decimals, Mathematics (77.83) is just ahead of Biology (77.80).
5.
Course | Lowest | Highest | Range | Median |
|---|---|---|---|---|
Mathematics | 55 | 99 | 44 | 77 |
Computer Science | 58 | 95 | 37 | 86 |
Biology | 61 | 94 | 33 | 77 |
English | 64 | 90 | 26 | 79 |
Mathematics has the widest spread. English has the narrowest.
SELECT course, MIN(score) AS lowest, MAX(score) AS highest, MAX(score) - MIN(score) AS spread
FROM data
GROUP BY course
ORDER BY spread DESCSpreadsheet: =MAXIFS(E2:E24; C2:C24; "Mathematics") and =MINIFS(...) the same way.
6. Highest: Emma Koch (10a), 91.75 from four courses. Lowest: Jonas Hoffmann (10b), 58.0 from two courses.
7. Six scores: Emma Koch, Mathematics 99; Noah Fischer, Computer Science 95; Emma Koch, Biology 94; Mia Becker, Mathematics 92; Emma Koch, Computer Science 91; Lea Wagner, English 90.
8.
Course | 10a | 10b | Gap |
|---|---|---|---|
Biology | 83.0 | 74.3 | 8.7 |
Computer Science | 88.3 | 71.0 | 17.3 |
English | 82.0 | 74.3 | 7.7 |
Mathematics | 86.0 | 69.7 | 16.3 |
The gap is largest in Computer Science. With so few scores per cell (two to four), one student can change a cell a lot.
9. The four student averages in 10a are 91.75, 85.0, 83.5 and 78.0; their average is 84.6. The class average of all scores is 85.3. They differ because the overall average counts every score once, so Emma Koch, with four high scores, weighs more than Sofia Richter with two.
10. Six students: Mia Becker, Noah Fischer, Lea Wagner, Emma Koch, Sofia Richter and Luis Klein. Only Paul Schaefer and Jonas Hoffmann have no score above 79.13. This is also the last "School scores" task in the SQL sandbox, solved there with a subquery.
Ideas
Spreadsheets: a pivot table of average score by course and class.
Statistics: the median and range per course, and which course has the widest spread.
SQL: the six "School scores" tasks in the sandbox, which split the data into three tables and practise joins.
Charts: a column chart of the course averages per class. Does it look fair to say one class is "better"?
Discussion: what would you need to know before comparing two teachers by these averages?
Common mistakes
Averaging the class averages or the student averages instead of all scores, as task 9 shows.
Comparing students who took different courses as if they had taken the same tests.
Reading a gap between groups of two or three scores as a firm result. Small groups vary a lot by chance.
The data is public domain under CC0 1.0: use it however you like.
