Here I see how many questions you have in each industry:
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 are 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
That is only cold cuts and groceries that responded.
In the part of the select where I put: resp_area <> '1'
this sector is the management.
I need the manager to only be able to respond when the answers are the same (same quantity), ie, he can only respond when all sectors have already answered.
How could you create this rule?