SELECT SUM(`range`)
FROM
(SELECT
`id`,
`id_test`,
`id_question`,
CASE
WHEN SUM(`range`) < 0
THEN 0
ELSE SUM(`range`)
END AS "range"
FROM
`test_range`
GROUP BY
`id_test`,
`id_question`)