随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253


代码文件:
//分组条件可以是 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 2009-05-28 17:54  万一  阅读(...)  评论(...编辑  收藏