EasySQL
Exam Score Stats per Subject
SQLDatabases
Write a SQL query that returns, for each subject, the number of students,
the lowest score, and the highest score. Order the results by subject name.
Table: exam_scores
| id | student | subject | score |
|---|---|---|---|
| 1 | Alice | Math | 75 |
| 2 | Bob | Math | 85 |
| 3 | Carol | Science | 60 |
| 4 | Dave | Science | 90 |
| 5 | Eve | Math | 92 |
| 6 | Frank | Science | 78 |
Expected output (columns: subject, students, lowest, highest)
Math|3|75|92
Science|3|60|90Sample tests
Test #12 subjects, 3 students each
Input: "CREATE TABLE exam_scores (id INTEGER, student TEXT, subject TEXT, score INTEGER);\nINSERT INTO exam_scores VALUES\n (1, 'Alice', 'Math', 75),\n (2, 'Bob', 'Math', 85),\n (3, 'Carol', 'Science', 60),\n (4, 'Dave', 'Science', 90),\n (5, 'Eve', 'Math', 92),\n (6, 'Frank', 'Science', 78);"
Output: "Math|3|75|92\nScience|3|60|90"