select count(*)
from conversion, outer wdep_inv, outer winv_hist, fam_names, outer wdep_code
where conversion.dep_code = wdep_code.dep_code and wdep_inv.dep_code = conversion.dep_code
and winv_hist.cust_num='0713010' and winv_hist.mth='11'
and winv_hist.dep_code=conversion.dep_code and winv_hist.yr='1999'
and fam_names.bf_name ='100 PIPERS' and conversion.brand_fam_code = fam_names.bf_code
and wdep_code.cust_num='0713010' and conversion.dep_code in (select distinct
dep_code from product_code where item_active='Y') and conversion.dep_code not in
(select dep_code from wdep_code where wdep_code.cust_num='0713010' and wdep_code.active = 'N')
and wdep_inv.yr='1999' and wdep_inv.mth=12 and wdep_inv.cust_num='0713010'
and wdep_inv.post_yn='N'