克莉丝杀人网站 下载:SQL语句在Delphi里怎么改?

来源:百度文库 编辑:高校问答 时间:2024/04/30 14:00:16
procedure TFrmConn.BitBtn5Click(Sender: TObject);
begin
connDate.Connected:=true;
adoquery.Close;
adoquery.SQL.Clear;
adoquery.SQL.Add('select str(100*sum(case when cj<60 then 0 else 1 end)/count(id))+'%' from '+edit1.text+');
showmessage(memo1.Lines.Text);
adoquery.Open;
adoquery.Active:=true;
end;

procedure TFrmConn.BitBtn10Click(Sender: TObject);
begin
connDate.Connected:=true;
adoquery.Close;
adoquery.SQL.Clear;
adoquery.SQL.Add('select count(cj) from '+edit1.text+');
showmessage(memo1.Lines.Text);
adoquery.Open;
adoquery.Active:=true;
end;
(id是学生学号,cj是成绩。第一个我是用来计算学生成绩及格率的。第二个是用来计算班级人数的。 )
1.adoquery.SQL.Add('select str(100*sum(case when cj<60 then 0 else 1 end)/count(id))+'%' from '+edit1.text+');
2.adoquery.SQL.Add('select count(cj) from '+edit1.text+');
上面2句运行不能通过,但在SQL查询分析器里可以通过。请问这2句应该怎么改?非常感谢!!!
谢谢。第二句解决了,但第一句还是运行不过去。

引号明显不对称
1.adoquery.SQL.Add('select str(100*sum(case when cj<60 then 0 else 1 end)/count(id))+'%' from '+edit1.text+'');
2.adoquery.SQL.Add('select count(cj) from '+edit1.text+'');