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=空闲率
(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=空闲率
select a.ID,a.母板名称 from a,b
where (b.空闲率<'n') and (a.ID = b.ID)
where kx_num/dz_num < percent
from 母板表 a,
(select 母板ID
from 端子表
group by 母板ID
having sum(decode(状态,'空闲',1,0))/count(*)>某个值) b
where a.母板ID=b.母板ID;