select a.* from 表a a join(
select a,c=max(c) from 表1 group by a
)b on a.a=b.a and a.c=b.c

解决方案 »

  1.   

    --上面写错表名
    select a.* from 表1 a join(
    select a,c=max(c) from 表1 group by a
    )b on a.a=b.a and a.c=b.c
    order by a.a
      

  2.   

    --测试--测试数据
    create table 表1(a int,b char(1),c decimal(10,2))
    insert 表1 select 1,'c',50.00
    union  all select 2,'t',100.00
    union  all select 1,'t',200.00
    union  all select 1,'r',1500.00
    union  all select 2,'r',700.00
    union  all select 3,'t',500.00
    union  all select 3,'c',2000.00
    go--查询
    select a.* from 表1 a join(
    select a,c=max(c) from 表1 group by a
    )b on a.a=b.a and a.c=b.c
    order by a.a
    go--删除测试
    drop table 表1/*--测试结果
    a           b    c            
    ----------- ---- ------------ 
    1           r    1500.00
    2           r    700.00
    3           c    2000.00(所影响的行数为 3 行)
    --*/
      

  3.   

    select b,max(c) from tab group by (b) 
    已经测试过了,没有问题