OneBug This week's bugs
Spot the bug SQL
1
-- Per-student test report for the term.
2
-- (passed and total are integer columns; total is never 0)
3
SELECT
4
    student_id,
5
    total - passed AS failed,
6
    passed / total AS pass_rate,
7
    ROUND(100.0 * passed / total, 1) AS pass_pct,
8
    CASE WHEN passed >= total THEN 'complete' ELSE 'partial' END AS status
9
FROM results
10
ORDER BY pass_rate DESC;

Read the full write-up for this bug (spoilers)