2
I have the following query:
SELECT
ROUND((( notaAmbiente +
notaApresentacaoDasPizzas +
notaQualidadeDosProdutos +
notaVariedadeDeSabores +
notaAtendimentoNaLoja +
notaAtendimentoNoTel +
notaAgilidadeNaEntrega +
notaCustoBeneficio +
notaPromocoes +
notaSite +
notaSatisfacao + notaSatisfacao) / 12) / 0.5, 0) * 0.5 AS mediaNotaOpiniao
FROM tbOpiniao
In this query I take the notes of each type of evaluation, sum and divide to get the average. However, in the middle of these notes there can be a value of 0 (referring to "I don’t know how to say" when filling out the form that I register with the bank), so I can’t use this value in the division, because it will affect the evaluation in the wrong way.
What I’d like to do is remove the column from the division account when its value is 0, subtracting 1 from 12, which is the amount of columns I use to average.
I thought of putting in place of 12 something of the type (SELECT COUNT(*) WHERE column <> 0), but there are other columns besides those of select in the table.