1
Good morning!
I wanted to calculate the percentage of how many times a classification appears between two dates, the classifications are distributed in "red", "yellow" and "green".
This is the table "questionario":
I tried it this way:
$percentagem_verm=mysqli_query($link,"SELECT COUNT(q.pergunta_id) / t.total * 100 as perc, classificacao FROM questionario q,
( SELECT COUNT(*) AS total FROM questionario) t
WHERE q.classificacao = 'vermelho' AND data BETWEEN '".$_POST["datainicial"]."' AND '".$_POST["datafinal"]."'
GROUP BY q.classificacao "));
The dates I picked up by the URL and it works right, but the percentage that returns is wrong, it is only correct when I choose all the information from the database, but if it is a specific date it is all wrong...
Perfect!! It worked just right, I added only the condition
where q.classificacao='vermelho'
!! Thank you very much– Ana
Ah, @Ana Okay. I didn’t pay attention to that detail. In the case of this filter it should only be in the external select. I will edit in the reply
– Diego Rafael Souza
Yes, I put out
– Ana