Select * from 类别 Where Exists(Select * from 玩具 Where 类别号=类别.类别号 Having Count(*)>3)

解决方案 »

  1.   

    你好,非常谢谢你刚才对我的问题的回复,让我想了一整晚上的头脑轻松了许多。
    我是个SQL Server初学者,对于你刚才的回复有点地方不是很明白,能再帮帮我吗?你的回复:
    Select * from 类别 Where Exists(Select * from 玩具 Where 类别号=类别.类别号 Having Count(*)>3)这里面的 Having Count(*)>3 中的“*”是对所有列做Count吧,怎么能确定是对“类型号”这一列进行的计算呢?
    对于Having 在没有 order by的情况下实在不知道怎么用。如有时间望能帮我指点一下,谢谢啦!
      

  2.   

    select *
    from 玩具,类别
    group by 类别号
    having count(*)>3  
    where 玩具.类别号=类别号
      

  3.   

    谢谢大家,在大家的帮助后我总结了一下:
    ---in方法实现select 类别号,类别名 from 类别
    where 类别号 in 
    (select 类别号 from 玩具
    group by 类别号
    having count(类别号)>=3
    )---exists 方法实现Select * from 类别 
    Where Exists
    (Select * from 玩具 
     Where 类别号=类别.类别号 
     having Count(*)>3)Select * from 类别 
    Where Exists
       (Select * from 玩具 
        Where 类别号=类别.类别号 
        group by 类别号 
        Having Count(*)>3)再次感谢 一天到晚游泳的鱼 和 The world is wonderful...!!!