select  aa,bb,max(cc),dd,ee  
from  table  
where  aa  =  @aa  
group  by  aa,bb,dd,ee;

解决方案 »

  1.   

    select  aa,bb,max(cc),dd,ee  
    from  table  
    where  aa  =  @aa  
    group  by  aa,bb
    或: select  @aa aa,bb,max(cc),dd,ee  
    from  table  
    where  aa  =  @aa  
    group  by  bb
      

  2.   

    Select a.aa,a.bb,a.cc.a.dd.a.ee from table a 
    join
    (Select bb,max(cc) as cc from table group by bb) b
    on a.bb = b.bb and a.cc = b.cc
    where a.aa = @aa
      

  3.   


    select  @aa aa,bb,max(cc),max(dd),max(ee)  
    from  table  
    where  aa  =  @aa  
    group  by  bb
      

  4.   

    必须把所有的select后的字段加入group by 语句中
    select  aa,bb,max(cc),dd,ee  
    from  table  
    where  aa  =  @aa  
    group  by  bb,aa,dd,ee
      

  5.   

    select  aa,bb,max(cc),dd,ee  
    from  table  
    where  aa  =  @aa  
    group  by  aa,bb,dd,ee或:
    select  max(aa),max(bb),max(cc),max(dd),max(ee  )
    from  table  
    where  aa  =  @aa  
    group  by  bb
      

  6.   

    是这个:select * from [table] tem where aa=@aa and cc=(select max(cc) from [table] where aa=@aa and bb=tem.bb)
      

  7.   

    select aa,bb,max(cc),dd,ee
    form table
    where aa=@aa and cc=max(cc)
    group by aa,bb,cc,dd,ee;
      

  8.   


    create table aiii (aa int,bb int,cc int,dd int,ee int)
    insert into aiii select 1,1,1,1,1
    insert into aiii select 1,1,3,1,1
    insert into aiii select 2,1,2,1,1
    insert into aiii select 3,1,3,1,1
    insert into aiii select 4,1,4,1,1
    insert into aiii select 4,1,1,1,1
    go
    select aa,bb,cc,dd,ee from aiii as a
    where cc=(select max(cc) from aiii as b where b.aa=a.aa)
    order by aa
      

  9.   


    select a.* 
    from aiii as a join (select aa,max(cc) as cc from aiii group by aa) as b
    on a.aa=b.aa and a.cc=b.cc
    order by a.aa