select distinct
a.question_id,
isnull(t5.val, 0) as '5',
isnull(t4.val, 0) as '4',
isnull(t3.val, 0) as '3',
isnull(t2.val, 0) as '2',
isnull(t1.val, 0) as '1'
from answers as a
left outer join (
select question_id, count(*) as val from answers where value = 5 group by question_id
) as t5 on a.question_id = t5.question_id
left outer join (
select question_id, count(*) as val from answers where value = 4 group by question_id
) as t4 on a.question_id = t4.question_id
left outer join (
select question_id, count(*) as val from answers where value = 3 group by question_id
) as t3 on a.question_id = t3.question_id
left outer join (
select question_id, count(*) as val from answers where value = 2 group by question_id
) as t2 on a.question_id = t2.question_id
left outer join (
select question_id, count(*) as val from answers where value = 1 group by question_id
) as t1 on a.question_id = t1.question_id;