有数据库如下 
  型号    序列号 
  A      0001 
  A      0002 
  A      0003 
  B      0001 
  B      0002 
怎么样统计 型号A的个数,如,例子中应为3
并把这个值赋给edit组件
该如何做?

解决方案 »

  1.   

    select counst(*) as num from 表 where 型号='A'
      

  2.   

    select 型号,count(*) as 个数 from 表名 group by 型号
      

  3.   


    with adoquery1 do
    begin
      close;
      sql.clear;
      sql.add('select counst(*) as num from 表 where 型号=''A''');
      open;
    end;
     edit1.text:=inttostr(adoquery1.FieldValues['num']);
      

  4.   

    select  型号,count(*) 个数 from 表
    group by 型号
      

  5.   

    edit1.text:= select 型号,count(*) as 个数 from 表名 group by 型号???这样写?
      

  6.   

          
    with adoquery1 do
    begin
      close;
      sql.clear;
      sql.add('select counst(*) as num from 表 where 型号=''A''');
      open;
    end;
    edit1.text :=adoquery1.FieldByName('num').asstring;
      

  7.   


    出现错误
    adoquery1:field 'num' not found怎么解决?
      

  8.   

    是count 他多打了一个"s" with adoquery1 do 
     begin 
       close; 
       sql.clear; 
       sql.add('select count(*) as num from 表 where 型号=''A'''); //“count”
       open; 
     end; 
      edit1.text:=inttostr(adoquery1.FieldValues['num']); 
      

  9.   

     with adoquery1 do 
     begin 
       close; 
       sql.clear; 
       sql.add('select count(*) as num from 表 where 型号=''A'''); //“count”
       open; 
     end; 
      edit1.text:=inttostr(adoquery1.FieldValues['num']); 
      

  10.   

     with adoquery1 do 
     begin 
       close; 
       sql.clear; 
       sql.add('select count(*) as num from 表 where 型号=''A'''); 
       open; 
     end; 
      edit1.text:=inttostr(adoquery1.FieldValues['num']);