如何统计范围内每个城市的发生率?我是sql的初学者。我有一张这样的table:
ID City 1 A 2 A 3 A 4 B 5 B 6 C 7 D 8 E 9 C
使用sql查询:
select `city` from `table` where `id` between 3 and 9
我能够提取3到9之间的城市名称。如何获取范围内每个城市的发生率:
City No A 1 B 2 C 2 D 1 E 1
0kjbasz61#
试试这个
select city, count(*) as No from `table` where id between 3 and 9 group by city
1条答案
按热度按时间0kjbasz61#
试试这个