有两个表    
 A  
  会议室名   会议地点    会议时间
      奥运会    上海      2008
      农博会     北京     2008
 B
   会议室名  用户名   
     奥运会   中国
     奥运会   美国
     奥运会   德国
     农博会   中国 现在要查询 用户数 大于3的 会议室的信息(根据B表判断用户数)
  即显示如下
      会议室名   会议地点  会议时间
      奥运会     上海       2008请问查询语句如何写,谢谢
    
 
  

解决方案 »

  1.   

     A   
      会议室名   会议地点    会议时间 
          奥运会    上海      2008 
          农博会     北京     2008 
     B 
       会议室名  用户名    
         奥运会   中国 
         奥运会   美国 
         奥运会   德国 
         农博会   中国  现在要查询 用户数 大于3的 会议室的信息(根据B表判断用户数) 
      即显示如下 
          会议室名   会议地点  会议时间 
          奥运会     上海       2008 select 会议室名,会议地点,会议时间  from A WHERE 会议室名 IN (SELECT 会议室名 FROM B group by 会议室名 havint count(1)>2)
      

  2.   

    汗,笔误select 会议室名,会议地点,会议时间  from A WHERE 会议室名 IN (SELECT 会议室名 FROM B group by 会议室名 having count(1)>2)
      

  3.   


    select * from A where [会议室名] in (select B.[会议室名] from B   
      group by B.[会议室名] having Count(*)>2)
      

  4.   

    create table #a(会议室名 varchar(10), 会议地点  varchar(10),  会议时间 varchar(10))create table #b(会议室名 varchar(10), 用户名  varchar(10))insert into #a select '奥运会','上海','2008' union all select '农博会','北京','2008'
    insert into #b select '奥运会','中国' union all select '奥运会','美国'union all select '奥运会','德国'union all select '农博会','中国'
    select * from #a where 会议室名 in
    (select 会议室名 from #b group by 会议室名 having count(1)>2)/*
    会议室名       会议地点       会议时间       
    ---------- ---------- ---------- 
    奥运会        上海         2008
    */
      

  5.   

    ------------------------------------------------
    create table A
    (
    会议室名 nvarchar(8) not null,
    会议地点 nvarchar(2) not null,
    会议时间 int 
    )insert 
    into A
    values('奥运会','上海','2008');insert 
    into A
    values('农博会','北京','2008');select *
    from A
    ------------------------------------------------
    create table B
    (
    会议室名 nvarchar(8) not null,
    用户名 nvarchar(5) not null
    )insert 
    into B
    values('奥运会','中国');insert 
    into B
    values('奥运会','美国');insert 
    into B
    values('奥运会','德国');insert 
    into B
    values('农博会','中国');select *
    from B
    ------------------------------------------------
    select 会议室名,会议地点,会议时间 
    from A
    where 会议室名 in
         (
    select 会议室名
    from B
    group by 会议室名 having count(*)>2
         )
      

  6.   

    select * from A where 会议室名 in
    (select 会议室名 from B group by 会议室名 having count(*)>2)
      

  7.   

    select * from A 
    where [会议室名] in 
     (select B.[会议室名] from B   
      group by B.[会议室名] having Count(*)>2)
      

  8.   

       
    select  a.会议室名 ,a.会议地点 , a.会议时间
    from   a  , b
    where  a.会议室名 = b.会议室名
    and    a.会议地点 = b.会议地点
    group by a.会议室名 ,a.会议地点 , a.会议时间
    having count(1) > 2