SELECT attribute_id, result
FROM TableName a
WHERE
(
SELECT COUNT(*)
FROM TableName b
WHERE a.attribute_id = b.attribute_id
AND a.result <= b.result
) <= 5
SELECT attribute_id, result
FROM TableName a
WHERE
(
SELECT COUNT(*)
FROM TableName b
WHERE a.attribute_id = b.attribute_id
AND a.result <= b.result
) <= 5