表结构:
表A(a,b)两列
表B(a,c,d)三列现在我要实现类似下面的语句
select A.* from A where A.a in(select B.a from B where B.d in
(select B.d,count(*) cc from B 
group by B.d
having count(*)>1)
)很明显上面的语句是不对的   我只是描述一下这个意思
希望各位帮忙解决下   先谢过

解决方案 »

  1.   

    把你两张表的字段说清楚啊,还有你要什么样子的操作,你的SQL语句都是错的,还叫我们看什么
      

  2.   

    我要表A中的数据
    表A的a和表B的a是关联的
    在表B中筛选出d列重复的条数大于1的数据不知道这样说清楚不...
      

  3.   


    declare @t1 table( a int,b int  )declare @t2 table( a int, c int , d int  )insert into @t1 values(1,1)
    insert into @t1 values(2,1)
    insert into @t2 values(1,2,null)
    insert into @t2 values(2,1,2)select * from @t1 where a in (select a from @t2 where d is not null  )看看是否满足需求
      

  4.   

    select a.*,b.* from tableA a inner join ( select a,c,count(d) from tableB group by a,c having count(d)>2) b on a.a=b.a  
      

  5.   


    意思是整个意思,但是条件不对 
    是求的d中重复的数据,不是为null的
      

  6.   

    insert into @t1 values(1,1)
    insert into @t1 values(2,1)
    insert into @t1 values(3,1)
    insert into @t2 values(1,2,1)
    insert into @t2 values(2,1,2)
    insert into @t2 values(3,1,2)select A.* from @t1 A
    inner join @t2 B on B.a = A.a
    inner join(
    select d from @t2 group by d having Count(*)>1)C on C.d = B.d是你3楼说的需求用这个
      

  7.   


    select A.* from A where A.a in(select B.a from B where B.d in 
    (select B.d from B 
    group by B.d 
    having count(*)>1)