select a.母板ID from 
(select 母板ID,count(1) zs from 端子表 group by 母板ID) a,
(select 母板ID,count(1) kx from 端子表 where 状态='空闲' group by 母板ID) b
where a.母板ID=b.母板ID and b.kx/a.zs > n; 
n=空闲率

解决方案 »

  1.   

    设母板表为a,端子表为b
    select a.ID,a.母板名称 from a,b 
    where (b.空闲率<'n') and (a.ID = b.ID)
      

  2.   

    select 母板ID from (select 母板ID,count(1) dz_num,sum(decode(状态,'空闲',1,0))kx_num from 端子表 group by 母板ID)  a
    where kx_num/dz_num < percent
      

  3.   

    select a.母板ID,a.母板名称 
      from 母板表 a,
           (select 母板ID 
              from 端子表
              group by 母板ID
              having sum(decode(状态,'空闲',1,0))/count(*)>某个值) b
      where a.母板ID=b.母板ID;