select a.* from td a where exists(select 1 from td where tid=a.tid and tmoney=a.tmoney and mid!=a.mid)

解决方案 »

  1.   

    declare @t table(mid varchar(50),tid varchar(50),tmoney decimal)
    insert into @t select 'm01','t01',20
    insert into @t select 'm02','t02',30
    insert into @t select 'm03','t03',50
    insert into @t select 'm04','t01',20select 
        a.mid 
    from 
        @t a 
    where 
        exists(select 1 from @t where tid=a.tid and tmoney=a.tmoney and mid!=a.mid)/*
    mid                                                
    ---
    m01
    m04
    */
      

  2.   

    select * from (select tid,tmoney from td where t.tid=td.tid and t.tmoney
    =td.tmoney)t
      

  3.   


    declare @t table(mid varchar(50),tid varchar(50),tmoney decimal)
    insert into @t select 'm01','t01',20
    insert into @t select 'm02','t02',30
    insert into @t select 'm03','t03',50
    insert into @t select 'm04','t01',20
    select * from @t where tid in(select tid from @t group by tid having count(*)>1)
      

  4.   

    select b.* 
    from tb b,(select tid,tmoney from tb group by tid,tmoney having count(*) >1 )a
    whee a.tid=b.tid and a.tmoney=b.tmoney