Basic report through SQL

Asked

Viewed 32 times

-2

Good afternoon, I am doing a system of evaluative questionnaires, where has several questionnaires with various questions that refer to a questionnaire, which can be opened or closed.

In the table of answers where I will pull the reports, it works with the following fields: ID / ID_RESPONDENTE / RESPONDENT / ID_PERGUNTA / QUESTION / QUESTION / TYPE / ANSWER

What I want is the following, take the amount of answers with value 'Very good', 'Good', 'Bad, 'Very Bad', Example:

Question / Answer / Quantity

Question 1 - Very good - 3

Question 1 - Good - 4


Question 2 - Very good - 5

Question 2 - Good - 2

  • https://www.devmedia.com.br/10-dicas-para-classificar-agrupar-e-sumarizar-dados-em-sql/27555

1 answer

0


I imagine that each row of this table has an answer to a question for one person (all 1:1:1), and that it is denormalized to (ID_PERGUNTA, QUESTION).

If this is the case, your SQL query should look like this:

SELECT Pergunta, Resposta, COUNT(*) AS Quantidade
FROM <tabela>
GROUP BY Pergunta, Resposta
ORDER BY 1, 2
  • thank you, I can understand

Browser other questions tagged

You are not signed in. Login or sign up in order to post.