0
want to show qtos customers I have in every city this sql works
but for example, if in Sao Paulo I don’t have any customer registration, it simply hides the city from my report how do I get zero customers he shows: São Paulo 0
SELECT count(*) as total, municipio.nome FROM clientes
inner join municipio on clientes.codmunicipio = municipio.codigo
group by codmunicipio
inner join
only brings the existing lines in both tables, for this you need to make a Join that brings everything from municipality, even if there are no lines in customers, can use aright join
. This will bring null, hence can convert to zero depending on the database you are using– Ricardo Pontual