日期:2014-05-17  浏览次数:20680 次

oracle表中sql问题
购买人 商品类型 数量
A      甲      1
B      乙      2
C      丙      2
A      丁      5
B      甲      3
1.使用sql求购买过俩种或者俩种以上的商品类型的购买人信息

------解决方案--------------------

select count(distinct 类型),购买人 from table_name group by 购买人

having count(distinct类型) >= 2

------解决方案--------------------

  SELECT CONSUMER 
    FROM SHOPPING_RECORD 
GROUP BY CONSUMER 
  HAVING COUNT(DISTINCT(goods_typ)) > 1;