如何判断相同的姓名中哪一条是最大的记录,并在最大记录上做上标记
 
编号  姓名    学科   成绩     标记
 1     王红    数学    60
 2     王红    语文    80
 3     王红    外语    90

解决方案 »

  1.   

    select max(成绩) as Grade from TableName where Name = '王红'
      

  2.   

    update 表 set 标记='MAX' where 编号=(select 编号 from 表 where Name = '王红' order by 成绩 desc)
      

  3.   

    update table set 标记=1
     where 编号 in (select 编号
                      from (select 编号, 姓名, max(成绩)
                            from table group by 编号, 姓名)
                   )
      

  4.   

    select max(成绩) as Grade from TableName where Name = '王红'
    只会显示成绩最大的那一条记录,并且只显示成绩一个字段
    as Grade 就是把该字段的字段名显示为Grade
    或者:
    select * from TableName where Name = '王红' order by 成绩
    那么查到的最后一条就是最大的成绩了。
      

  5.   

    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('select top 1 *,max(chengji) form table where name=''王红''');//u can change it is group by name;
    adoquery1.open;
    if adoquery1.recordcount>0 then
      begin
         adoquery1.edit;
         adoquery1.fieldbyname('biaoji').asstring:='1';
    end;
      

  6.   

    Little2000(test) 的方法是错误的!
    自我理解你的意思应该是
    1:
    select max(成绩) where 姓名=** 
    2:
    select max(成绩) group by 姓名
      

  7.   

    中间的from语句,我想你自己应该清楚在什么表!
    1:
    select max(成绩) from tablename where 姓名=** 
    2:
    select max(成绩) from tablename group by 姓名