我在MYSQL中有一个城市和县的列表,每个城市和县都代表一个独特的数据点。我想运行一个查询,计算每个不同县出现的次数。例如:
city state county
chantilly virginia fairfax
chantilly virginia fairfax
reston virginia fairfax
leesburg virginia loudon
ashburn virginia loudon
manassas virginia prince william
应该导致:
county count
fairfax 3
loudon 2
prince william 1
答案 0 :(得分:0)
select county, count(county) as Count from table group by county;