select max(BBB) max_bbb from table1 where AAA='MAN'; ... form1.caption:=adoquery1.fieldbyname('max_bbb').asstring;
----------------------------------------------
Function IThink(Boy,Girl : TPerson) : String; begin if Boy.钱 < 10W then Girl.Say(''滚!'') else begin if Girl.Anser = ''我愿意'' then Result := ''结婚'' else Result := IntToStr(88); end; 风过不折→百炼成尧 QQ: 7315910
where 子句第一个条件多余。 1、with query1 do begin close; sql.clear; sql.Add('select max(BBB) AS MaxValue from table1'); sql.Add(Format('where AAA = %s',[QuotedStr(MAN)])); open; end; 2、if NOT query1.Empty then Form1.Caption := IntToStr(query1['MaxValue']) else showmessage('未发现匹配的记录!');
----------------------------------------------
你可以这样 sql.Add('select max(BBB) AS MaxValue from table1 '); sql.add('where aaa like '+'[a-z]%'+' and bbb ='+'man') ;
----------------------------------------------
-