场景:找出产品系列有多个分类的产品系列
解决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
解决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
本文介绍了一种SQL查询方法,用于找出拥有两个以上不同产品分类的产品系列。通过两步SQL语句实现:首先从数据库中筛选出每个产品系列及其对应的所有分类;接着统计每个系列拥有的分类数量,并筛选出符合条件的数据。
754

被折叠的 条评论
为什么被折叠?



