请教高手 我想返回统计的结果,然后将结果用EDIT控件将统计的结果显示出来 
例如Query1.SQL.Add('select count(distinct 学生学号)  from 学生成绩表 where 课程成绩>80 and 年级=2002 and 班级=106 and 课程编码=GS');
即统计106班课程编码为GS并且成绩大于80的学生人数,
如果在SQL中执行查询语句,会返回一个统计人数的结果,请问我如何才能将统计的结果用delphi控件显示出来

解决方案 »

  1.   

    Query1.SQL.Add('select count(distinct 学生学号) as total  //--取一个别名
     from 学生成绩表 where 课程成绩>80 and 年级=2002 and 班级=106 and 课程编码=GS');
    Edit1.Text := Query1.FieldByName('total').AsString;
      

  2.   

    ....
    sql.add('select count(distinct 学生学号) as 学生数  from 学生成绩表 where 课程成绩>80 and 年级=2002 and 班级=106 and 课程编码=GS')
    ...
    ...
    edit1.text:=query1.fieldvalues['学生数']
      

  3.   

    Query1.SQL.Add('select count(distinct 学生学号) as total  //--取一个别名
     from 学生成绩表 where 课程成绩>80 and 年级=2002 and 班级=106 and 课程编码=GS');
    Edit1.Text := Query1.FieldByName('total').AsString;
    这是这样。
      

  4.   

    edit1.text:=inttostr(adoquery1.fields[0].value);