0
I’m trying to develop a customer satisfaction survey application where the user answers some questions with numbers 1 to 10 and another yes or no.
In one of the reports, I show the average of each field of the bank, but in the fields of yes or no question, I’m saving 1 for yes and 2 for no.
I am doubtful if it is possible to solve only with the database, returning only the percentage of each field response.
SELECT COUNT(p.id_pesquisa)"pesquisas",
FORMAT(AVG(p.atendimento),2)"atendimento",
FORMAT(AVG(p.espera),2)"espera",
FORMAT(AVG(p.ambiente),2)"ambiente",
FORMAT(AVG(p.qualidade_produtos),2)"qualidade_produtos",
FORMAT(AVG((p.atendimento + p.espera + p.ambiente + p.qualidade_produtos)/4),2)'media'
FROM empresa e
INNER JOIN campanha c ON (e.id_empresa = c.id_empresa)
INNER JOIN pesquisa p ON (c.id_campanha = p.id_campanha)
WHERE c.id_empresa = 4
Thank you for the answer John, I really saw the need to create a view or Procedure. As it is around 3 years that I do not work with programming, I forgot a lot. I tried to create a view, but as the ID field of the table survey received a COUNT I could not filter more by the company ID. Have some advice?
– Neto Matiazi
I edited the answer to try to make it more complete and try to solve this problem of yours. If you still haven’t answered your question, try posting how your code is getting to make it easier to understand the problem.
– João Paulo M. Bandolin