SQL语言统计查询结果个数问题
time1 time2 location
1 1 B区107
1 2 B区107
1 3 B区107
1 4 B区107
1 5 B区107
2 1 B区107
2 2 B区107
2 3 B区107
2 4 B区107
2 5 B区107
3 1 B区107
3 2 B区107
3 3 B区107
3 4 B区107
4 3 B区107
5 2 B区107
1 1 B区109
1 2 B区109
1 3 B区109
1 4 B区109
1 5 B区109
2 1 B区109
2 2 B区109
2 3 B区109
2 4 B区109
2 5 B区109
3 1 B区109
3 2 B区109
3 3 B区109
3 4 B区109
3 5 B区109
3 6 B区109
4 1 B区109
4 2 B区109
4 3 B区109
4 5 B区109
4 6 B区109
1 1 B区111
1 3 B区111
1 5 B区111
2 2 B区111
2 3 B区111
2 4 B区111
3 1 B区111
3 2 B区111
3 3 B区111
3 5 B区111
4 1 B区111
4 2 B区111
4 3 B区111
4 5 B区111
1 1 B区113
1 2 B区113
1 3 B区113
1 4 B区113
1 6 B区113
2 1 B区113
2 2 B区113
2 3 B区113
2 5 B区113
3 1 B区113
各位大神。。。上面是mysql查询出来的结果。。我想知道每个location相同的行的个数并按此个数排序,sql语言应该怎么写
------解决方案--------------------
SQL code
select
location,count(location) as 个数
from
tb
group by
location
order by
count(location)
------解决方案--------------------
SQL code
select location,count(location)
from tb
group by location
order by count(location)