if (select count(*) from (select b,c from A group by b,c having count(*)=2))>0
begin 
      select max(A.a) from A join  (select b,c from A group by b,c having count(*)=2) AS B where A.b=B.b and A.c=B.c
END 

解决方案 »

  1.   

    select * from A where a in( select max(A),b,c from A group by b,c)
      

  2.   


    if (select count(*) from (select b,c from A group by b,c having count(*)=2))>0
    begin 
          select max(A.a) from A ,  (select b,c from A group by b,c having count(*)=2) AS B where A.b=B.b and A.c=B.c
    END
      

  3.   

    create table #Table1(
    f1 nvarchar(20),
    f2 nvarchar(20),
    f3 nvarchar(20),
    f4 nvarchar(20)
    )insert into #Table1(f1,f2,f3,f4)
    values('1','2','3','4')
    insert into #Table1(f1,f2,f3,f4)
    values('2','2','3','4')
    insert into #Table1(f1,f2,f3,f4)
    values('3','1','3','4')
    insert into #Table1(f1,f2,f3,f4)
    values('4','1','3','4')select t1.* from #table1 t1 right join 
      ( select f1 = max(f1), f2, f3--, f4
        from #Table1 
        group by f2, f3) t2 on t1.f1 = t2.f1 and t1.f2 = t2.f2 and t1.f3 = t2.f3drop table #Table1
      

  4.   

    修正一下:select a.* from A a join(select max(a) as a,b,c from A group by b,c)b
    on a.a=b.a