表A中的列ID可能有多个,并且有重复的,请用一条SQL语句把每个ID和该ID对应的总数查询出来
select count(id) from table1 group by id
select id,count(id) from a group by id
问题是把每个ID和该ID对应的总数查询出来 2楼的正确
count()聚合函数用来查询总数
group by id 则是按id分组 分组后相同id的只保留一条
select id,count(id) from a group by id
如果想看一共有哪几种ID可以用distinct来处理
select id,count(id) from a group by id
select distinct ID,count(ID) from A group by ID