0
People, someone can tell me why this query doesn’t work. In fact it works, but brings the values wrong way (duplicating the department field), as if distinct does not work.
select distinct r.departamento, s.status,
count(s.status) as quantidade from sac as s
inner join responsaveis as r on s.id_sac =
r.sac_id where r.departamento = 1 and s.status_sac = 1
Is the data return of your query the one from the image? But still your query is not right, apparently, in your case you should use a group by rather than distinct because of that Count.
– Marcelo Diniz
Note the image that the department duplicates, and sac_id also. I need distinct to work in this table and not in the table "Sac"
– Eduardo Santos
Explain better the data you want to bring and put the structure of the two tables
– Marcelo Diniz