本文整理自网络,侵删。
学习 SQL 语句 - Select(8): 分组条件
代码文件:
--------------------------------------------------------------------------------
//分组条件可以是 Where
procedure TForm1.Button1Click(Sender: TObject);
begin
with ADODataSet1 do begin
Close;
CommandText := 'SELECT Continent, AVG(Area) AS 平均面积 ' +
'FROM country WHERE Continent="South America" GROUP BY Continent';
Open;
end;
end;
//也可以是 Having
procedure TForm1.Button2Click(Sender: TObject);
begin
with ADODataSet1 do begin
Close;
CommandText := 'SELECT Continent, AVG(Area) AS 平均面积 ' +
'FROM country GROUP BY Continent HAVING Continent<>"South America"';
Open;
end;
end;
相关阅读 >>
Delphi 如何确定access数据库中存在某一个已知名的表
Delphi 文字的高度与宽度: canvas.textextent
Delphi removeinvalid截取字符串某个字符前面的字符
更多相关阅读请进入《Delphi》频道 >>