1.group by 分组
select spid,count(1) as productnum from tb_productinfo group by spid
分组后可以得使用聚合函数
结果
spid productnum
1001 3
10002 6
200010 46
使用having
select * from reportrecord where ly in(select ly from reportrecord r
group by r.ly
having count(*) > 1) for update