查询会员表里开通会员数量大于10的会员省份及对应会员数量,并把省份名称从地址表里匹配出来
group by 分组,功能类似于EXCEL的数据透视,可以通过count(*)等对分组结果进行运算,注意查询的元素都必须包含在分组group by后面
having 添加分组筛选条件
select m.Province,S.Name,count(*)
from member as m,ShippingArea as s
where m.Status=1
and m.Province=s.ShippingAreaID
group by m.Province,S.Name having count(*)>10;
来源:博客园
作者:野望之风
链接:https://www.cnblogs.com/webwangjie/p/11425463.html