`

Group by 用法

 
阅读更多

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
 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics