select max(A),
       [max(A)对应C的值]=(select top 1 c from 表 where A=(select max(A) from 表 where d = aa.d)),
       max(B),
       [max(A)对应C的值]=(select top 1 c from 表 where B=(select max(B) from 表 where d = aa.d)),
from 表 aa

解决方案 »

  1.   

    select distinct D,max(A),
           [max(A)对应C的值]=(select top 1 c from 表 where A=(select max(A) from 表)),
           max(B),
           [max(A)对应C的值]=(select top 1 c from 表 where B=(select max(B) from 表))
    from 表
      

  2.   

    或:
    select max(A),
           [max(A)对应C的值]=(select top 1 c from 表 aa where A=(select max(A) from 表 where d = aa.d)),
           max(B),
           [max(A)对应C的值]=(select top 1 c from 表 aa where B=(select max(B) from 表 where d = aa.d)),
    from 表
      

  3.   


    select D,max(A),
           (select top 1 c from 表 where d=tem.d and A=(select max(A) from 表)) [max(A)对应C的值],
           max(B),
           (select top 1 c from 表 where d=tem.d and B=(select max(B) from 表)) [max(A)对应C的值]
    from 表 tem group by D
      

  4.   

    select D,max(A),
           (select top 1 c from 表 where d=tem.d and A=(select max(A) from 表 where d=tem.d)) [max(A)对应C的值],
           max(B),
           (select top 1 c from 表 where d=tem.d and B=(select max(B) from 表 where d=tem.d)) [max(A)对应C的值]
    from 表 tem group by D
      

  5.   

    select * from (
    select * from 表 tem where A=(select max(A) from 表 where D=tem.D)) a,(
    select * from 表 tem where B=(select max(B) from 表 where D=tem.D)) b where a.D=b.D