SQL1:
SELECT COUNT(*)
FROM tbm_order_queue_his a, tbm_main_inst_his c
WHERE a.order_id = c.order_id
AND a.state = 1
AND c.is_new = 1
AND a.offer_id IN (SELECT tso.offer_id
FROM tpm_service_offer tso
WHERE tso.offer_type_id = 1)
AND a.prod_id IN (SELECT tmp.main_prod_id
FROM tpm_main_product tmp
WHERE tmp.prod_big_id in (11, 12))
AND c.company_id in
(select tc.company_id
from tsm_company tc
start with tc.company_id = 1668
connect by PRIOR tc.company_id = tc.upper_id)
AND a.finish_time BETWEEN
to_date('2012-02-01 11:35:17', 'yyyy-mm-dd hh24:mi:ss') AND
to_date('2012-02-28 11:35:20', 'yyyy-mm-dd hh24:mi:ss')
SQL2:
SELECT count(*)
FROM tbm_order_queue_his a, tbm_main_inst_his c, tbm_cust_his d
WHERE a.order_id = c.order_id
AND a.order_id = d.order_id
AND a.state = 1
AND c.is_new = 1
AND d.is_new = 1
AND a.offer_id IN (SELECT tso.offer_id
FROM tpm_service_offer tso
WHERE tso.offer_type_id = 1)
AND a.prod_id IN (SELECT tmp.main_prod_id
FROM tpm_main_product tmp
WHERE tmp.prod_big_id in (11, 12))
AND c.company_id in
(select tc.company_id
from tsm_company tc
start with tc.company_id = 1668
connect by PRIOR tc.company_id = tc.upper_id)
AND a.finish_time BETWEEN
to_date('2012-02-01 11:35:17', 'yyyy-mm-dd hh24:mi:ss') AND