购物人      商品名称     数量
A            甲          2
B            乙          4
C            丙          1
A            丁          2
B            丙          5
给出所有购入商品为两种或两种以上的购物人记录这个返回 A
B

解决方案 »

  1.   

    select 购物人,[count]=count(商品名称) from 表名 group by 购物人 having count(商品名称)>1
      

  2.   

    对不起
    这个怎么做,不好意思哈
    用一条SQL语句 查询出每门课都大于80分的学生姓名  name   kecheng   fenshu 
    张三     语文       81
    张三     数学       75
    李四     语文       76
    李四     数学       90
    王五     语文       81
    王五     数学       100
    王五     英语       90
      

  3.   

    itblog(i like i do) 
    select 购物人,[count]=count(商品名称) from 表名 group by 购物人 having count(商品名称)>1
    -----------------------------------------------------------------------------------
    你这个是错的
    我指的是不同种类的商品而不是你所说的商品的个数
      

  4.   

    select 购物人,[count]=count(distinct 商品名称) from 表名 group by 购物人 having count(distinct 商品名称)>1
      

  5.   

    --表
    create table sd(name varchar(10),kecheng varchar(10),fenshu int)
    insert sd select '张三','语文',81
    union all select '张三','数学',75
    union all select '李四','语文',76
    union all select '李四','数学',90
    union all select '王五','语文',81
    union all select '王五','数学',100
    union all select '王五','英语',90
    --执行语句
    select * from sd where name not in(select name  from sd a where exists(select * from sd where name=a.name and a.fenshu<80))
    --or
    select distinct name from sd where name not in(select name  from sd a where exists(select * from sd where name=a.name and a.fenshu<80))
      

  6.   

    ok 全部解决!!
    结贴了
    多谢itblog(i like i do)!!!!!!!!!!!