2
Here I see how many questions you have in each sector:
SELECT
a.area_id AS ID_AREA,
a.area_desc AS AREA_DESC,
count(sb.sub_area_cod) AS TOTAL
FROM
relacaoperg AS rp
INNER JOIN area AS a ON rp.id_area = a.area_id
INNER JOIN sub_area AS sb ON rp.id_subgrupo = sb.sub_area_cod
WHERE
id_area <> '1' GROUP BY AREA_DESC ASC;
Returns as follows:
id desc total
2 FRENTE 18
3 FRIOS 36
4 ACOUGUE 35
5 MERCEARIA 27
6 HORTIFRUTI 31
7 PADARIA 33
Here I see the answers:
SELECT
a.area_id AS ID_AREA,
a.area_desc AS AREA_DESC,
count(resp_area) AS TOTAL
FROM respostas as r
INNER JOIN area AS a ON r.resp_area = a.area_id
INNER JOIN sub_area AS sb ON r.resp_subgrupo = sb.sub_area_cod
WHERE
resp_area <> '1'
AND resp_questionario='3'
GROUP BY resp_area;
Returns as follows:
id desc total
3 FRIOS 32
5 MERCEARIA 27
In other words, only cold cuts and groceries who responded.
In the select part where I put: resp_area <> '1'
this sector is the management.
I need the manager to be able to answer only when the answers are equal to the questions (same amount), that is, he can only answer when all sectors have already answered.
How could I make that rule ?
Bro, I’m not sure what the query would look like, but basically you have to add up the total of the questions of all sectors, like 18+36+35... and compare with the total of the questions, if it is the same you free to manage rs. You want to do this in php or sql?
– Raylan Soares
PHP.thus would give yes, more I also wanted to display to him, which sector has not responded yet.
– Otacio Barbosa