Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1957600
  • 博文数量: 176
  • 博客积分: 1857
  • 博客等级: 上尉
  • 技术积分: 2729
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-14 22:55
个人简介

吾生有涯,而知无涯,适当止学.循序渐进,步步提升 Talk is cheap, show me the code.

文章分类

全部博文(176)

文章存档

2019年(1)

2018年(14)

2017年(20)

2016年(31)

2015年(15)

2014年(5)

2013年(10)

2012年(80)

分类: Mysql/postgreSQL

2012-08-20 16:59:32

场景:找出产品系列有多个分类的产品系列


解决sql语句方法:
select a.series_name,count(a.product_category) from ( select distinct series_name,product_category from t_app_digital_product) a group by a.series_name having count(a.product_category) >1;

第一步:

select distinct series_name,product_category from t_app_digital_product

找出需要的排列组合,一个系列名称对应的多个产品类别。

第二步:

select a.series_name,count(a.product_category) from ( select distinct series_name,product_category from t_app_digital_product) a group by a.series_name

分组,按照系列名称统计有多个产品类别个数。

统计2个以上的. having count(a.product_category) >1
阅读(1438) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~