Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá,
eu tenho uma sql para mostrar as respostas de 75 questoes de um questionario socio economico..
as pessoas respondem o questionario e salva no banco como na imagem abaixo:
http://imageshack.us/photo/my-images/856/img1yb.jpg/
e eu tenho uma query que mostra as perguntas com suas respostas...
mas quando mostro a qntde de respostas da coluna 'sim', por exemplo, ela repete o sql count, nao mostra qntas respostas teve cada pergunta!
Vou colocar o sql para vcs ver:
SELECT
(select count(*) from respostaaluno where sim=1 and IdPergunta=IdPergunta) as qtdSim,
(select count(*) from respostaaluno where nao=1 and nao is not null) as qtdNao,
(select count(*) from respostaaluno where nar=1 and nar is not null) as qtdNar,
(select count(*) from respostaaluno where i=1 and i is not null) as qtdI,
(select count(*) from respostaaluno where r=1 and r is not null) as qtdR,
(select count(*) from respostaaluno where b=1 and b is not null) as qtdB,
(select count(*) from respostaaluno where o=1 and o is not null) as qtdO,
(select count(*) from respostaaluno where e=1 and e is not null) as qtdE,
(select count(*) from respostaaluno where re=1 and re is not null) as qtdRe,
(select count(*) from respostaaluno where ru=1 and ru is not null) as qtdRu,
(select count(*) from respostaaluno where sempre=1 and sempre is not null) as qtdSempre,
(select count(*) from respostaaluno where asvezes=1 and asvezes is not null) as qtdAsvezes,
(select count(*) from respostaaluno where raramente=1 and raramente is not null) as qtdRaramente,
(select count(*) from respostaaluno where nunca=1 and nunca is not null) as qtdNunca
FROM respostaaluno GROUP BY IdPergunta
Não sei o que está errado, alguem tem uma solução??
Obrigado.
Carregando comentários...