需求是数据库里面有个字段是A01, 值为0 (未经历) 1(合格) 2(不合格) 时间字段为“AIRDATE”
如果值为0 不参与评比。。我需要求某段时间内  A01字段得合格率。  在线等大侠。。

解决方案 »

  1.   

    select COUNT(DECODE(A01,1,1,0))/COUNT(1)*100 合格率 FROM 表 where a01 !=0
      

  2.   

    需求是数据库里面有个字段是A01, 值为0 (未经历) 1(合格) 2(不合格) 时间字段为“AIRDATE” 
    如果值为0 不参与评比。。我需要求某段时间内  A01字段得合格率。  在线等大侠。。 
    例如:
    A01  AIRDATE
    0    2009.1
    1    2009.2
    1    2009.3
    2    2009.4
    2    2009.5
    0    2009.6                  有这样的数据。  肉眼观察后得出结论在2009年本年  合格率为 2除以6 33.333333333333333%如果数据很多不建议用肉眼观察,可以用sql
    aaa 是你表的名字  select count(1) tt1 from aaa 查询总数     select count(1) tt2 from aaa where a=1 查询合格的数
     select ab.tt2/ac.tt1*100% from (select count(1) tt1 from aaa where AIRDATE 时间条件 ) ab,
                   (select count(1) tt2 from aaa where a=1 and AIRDATE 时间条件) ac的出的就是率!!!!
      

  3.   

    select sum(decode(a,1,1,0))/COUNT(1) from aaa 
    这样可以
      

  4.   

    select sum(decode(a,1,1,0))/COUNT(1) from aaa where a01 !=0 
      

  5.   

    select SUM(DECODE(A01,1,1,0))/COUNT(1)*100 合格率 FROM 表 where a01 !=0 
      

  6.   

    select sum((select count(1) from aaa where a101=1)/(select count(1) from aaa where a101<>0)) from dual这个绝对可以