星辰日月00

欲多则心散,心散则志衰,志衰则思不达也!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
本文来自:万一
代码文件:
//分组条件可以是 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;
posted on 2012-02-18 15:21  星辰日月00  阅读(283)  评论(0编辑  收藏  举报