select A,D from tablename t1
where checksum(*)  = (select top 1 checksum(*) from tablename where a = t1.a order by b desc,c desc)

解决方案 »

  1.   

    select A,B=max(B) From Table group by A having count(*)=1
    union all
    Select * From table k where exists(select * From (
    Select A,B,C=max(C) From Table b Where Exists (select *  From
    (select A,B=max(B) From Table group by A having count(*)>1) c where A=b.B And B=b.B)
     Group by A,B Having count(*)=1 ) g where A=k.A And B=k.B And C=b.C )
    Union all
    Select * From table k where exists(select * From (
    Select A,B,C=max(C) From Table b Where Exists (select *  From
    (select A,B=max(B) From Table group by A having count(*)>1) c where A=b.B And B=b.B)
     Group by A,B Having count(*)>1 ) g where A=k.A And B=k.B And C=b.C )
      

  2.   

    Create table tb(A int, B int,C int,D int)
    insert into tb
    select 1,2,3,4
    union all
    select 1,5,3,2
    union all
    select 1,4,9,2
    union all
    select 1,9,3,9
    union all
    select 2,3,9,12
    union all
    select 2,8,1,11
    union all
    select 2,8,12,13
    union all
    select 3,4,8,12
    union all
    select 4,12,3,4select * 
    from tb
    select A,D
    from tb t1
    where checksum(*)  = ( select top 1 checksum(*) 
    from tb where a = t1.a 
    order by b desc,c desc)
    drop table tb