0
One possibility is to use count
, distinct
and group by
This query presents the number of neighborhoods per city and neighborhood.
SELECT city,
neighborhood,
count(neighborhood) as qtd_bairros
FROM <nomenclatura da tabela>
GROUP BY city,
neighborhood
ORDER BY city, neighborhood DESC
This query presents the number of neighborhoods per city:
SELECT city,
count(DISTINCT neighborhood) qtd_bairros
FROM <nomenclatura da tabela>
GROUP BY city
ORDER BY city DESC
How is your table that stores this information?
– João Paulo Araujo
CREATE TABLE tb_listings ( "advertiser_id" varchar, "listing_id" varchar, "portal" varchar, "city" varchar, "Neighborhood" varchar);
– user156772