便捷网站建设哪家好,产品管理系统,网站建设程序都有哪些,网站建设交流会上午参加了个计算机英语三级考试#xff0c;回来后BA同事让帮忙统计数据。可能刚考完试思维比较混乱#xff0c; 整理了好大一会没有想明白怎么写。 最后挣扎了快一个小时终于想起来#xff0c;记下来留个备份#xff1b; select store_no, brand_code, count(distinct t.d…上午参加了个计算机英语三级考试回来后BA同事让帮忙统计数据。可能刚考完试思维比较混乱 整理了好大一会没有想明白怎么写。 最后挣扎了快一个小时终于想起来记下来留个备份 select store_no, brand_code, count(distinct t.dealer_code)from juran.emall_booth_contract tgroup by store_no, brand_codehaving count(distinct t.dealer_code) 1 如果统计表数量则是selelct count(*) from emall_booth_contract 如果统计门店数量select store_no,count(*) from emall_booth_contract 统计门店数量大于1select store_no from emall_booth_contract group by store_no having count(*) 1 当时怎么想不明白怎么统计门店下品牌数量其实select两列的话是按照那两列分组统计没组下有多少个品牌 加上distinct进行重复值去除。 having条件是把每组下数量大于1的结果查出转载于:https://www.cnblogs.com/xiaoheshang/p/4566028.html