主题:简单的统计问题
procedure TForm12.Button1Click(Sender: TObject);
begin
ADOQuery1.Filter:='课程序号='''+edit1.Text+'''';
ADOQuery1.Filtered:=True;
ADOQuery1.Open;
if ADOQuery1.RecordCount=1 then
begin
ADOQuery1.Close;
adoquery1.Parameters[0].Value:=edit1.Text;
ADOQuery1.Open;
ADOQuery1.Close;
ADOQuery1.sql.clear;
ADOQuery1.SQL.Add('SELECT COUNT(*),AVG(成绩),MAX(成绩),MIN(成绩)');
ADOQuery1.SQL.Add('FROM 成绩信息表');
ADOQuery1.SQL.Add('WHERE 课程序号='''+edit1.text+'''');
ADOQuery1.Open;
Edit6.Text:=ADOQuery1['COUNT'];
Edit2.Text:=ADOQuery1['MAX'];
Edit4.Text:=ADOQuery1['AVG'];
Edit3.Text:=ADOQuery1['MIN'];
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT COUNT(*)');
ADOQuery1.SQL.Add('FROM 成绩信息表');
ADOQuery1.SQL.Add('WHERE 课程序号='''+edit1.Text+'''');
ADOQuery1.SQL.Add('AND 成绩<60');
ADOQuery1.Open;
Edit5.Text:=ADOQuery1['COUNT'];
end
else
showmessage('不存在此课程号');
end;
end.
大家帮我修改一下 先谢谢了
begin
ADOQuery1.Filter:='课程序号='''+edit1.Text+'''';
ADOQuery1.Filtered:=True;
ADOQuery1.Open;
if ADOQuery1.RecordCount=1 then
begin
ADOQuery1.Close;
adoquery1.Parameters[0].Value:=edit1.Text;
ADOQuery1.Open;
ADOQuery1.Close;
ADOQuery1.sql.clear;
ADOQuery1.SQL.Add('SELECT COUNT(*),AVG(成绩),MAX(成绩),MIN(成绩)');
ADOQuery1.SQL.Add('FROM 成绩信息表');
ADOQuery1.SQL.Add('WHERE 课程序号='''+edit1.text+'''');
ADOQuery1.Open;
Edit6.Text:=ADOQuery1['COUNT'];
Edit2.Text:=ADOQuery1['MAX'];
Edit4.Text:=ADOQuery1['AVG'];
Edit3.Text:=ADOQuery1['MIN'];
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT COUNT(*)');
ADOQuery1.SQL.Add('FROM 成绩信息表');
ADOQuery1.SQL.Add('WHERE 课程序号='''+edit1.Text+'''');
ADOQuery1.SQL.Add('AND 成绩<60');
ADOQuery1.Open;
Edit5.Text:=ADOQuery1['COUNT'];
end
else
showmessage('不存在此课程号');
end;
end.
大家帮我修改一下 先谢谢了