select max(成绩) as Grade from TableName where Name = '王红'
update 表 set 标记='MAX' where 编号=(select 编号 from 表 where Name = '王红' order by 成绩 desc)
update table set 标记=1 where 编号 in (select 编号 from (select 编号, 姓名, max(成绩) from table group by 编号, 姓名) )
select max(成绩) as Grade from TableName where Name = '王红' 只会显示成绩最大的那一条记录,并且只显示成绩一个字段 as Grade 就是把该字段的字段名显示为Grade 或者: select * from TableName where Name = '王红' order by 成绩 那么查到的最后一条就是最大的成绩了。
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;
Little2000(test) 的方法是错误的! 自我理解你的意思应该是 1: select max(成绩) where 姓名=** 2: select max(成绩) group by 姓名
中间的from语句,我想你自己应该清楚在什么表! 1: select max(成绩) from tablename where 姓名=** 2: select max(成绩) from tablename group by 姓名
where 编号 in (select 编号
from (select 编号, 姓名, max(成绩)
from table group by 编号, 姓名)
)
只会显示成绩最大的那一条记录,并且只显示成绩一个字段
as Grade 就是把该字段的字段名显示为Grade
或者:
select * from TableName where Name = '王红' order by 成绩
那么查到的最后一条就是最大的成绩了。
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;
自我理解你的意思应该是
1:
select max(成绩) where 姓名=**
2:
select max(成绩) group by 姓名
1:
select max(成绩) from tablename where 姓名=**
2:
select max(成绩) from tablename group by 姓名