How can I use COUNT and DISTINCT in MYSQL to create a separate count for each distinct value? -


i have list of cities , counties in mysql each represent unique datapoint. want run query count how many times each different county appears. example:

city            state       county chantilly       virginia     fairfax chantilly       virginia     fairfax reston          virginia     fairfax leesburg        virginia     loudon ashburn         virginia     loudon manassas        virginia     prince william  

should result in:

county        count fairfax          3 loudon           2 prince william   1 

select county, count(county) count table group county;  

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -