SELECT DISTINCT h.capture_id , ' ' , hbo1.bo_id , hbo2.bo_id FROM PS_RO_CUSTOMER cust , ps_ro_boid bo1 , ps_ro_boid bo2 , ps_ro_header h , ps_ro_boid hbo1 , ps_ro_boid hbo2 WHERE h.capture_id = cust.capture_id AND h.rbtnewacct = 'R' AND bo1.capture_id = cust.capture_id AND bo2.capture_id = cust.capture_id AND hbo1.capture_id = h.capture_id AND hbo2.capture_id = h.capture_id AND (bo1.uid20 = cust.uid20f_r_bill AND hbo1.uid20 = h.uid20f_r_bill) AND (bo2.uid20 = cust.uid20f_r_billc AND hbo2.uid20 = h.uid20f_r_billc) UNION SELECT DISTINCT cust2.capture_id , cust2.uid20 , bo2.bo_id , bo22.bo_id FROM PS_RO_CUSTOMER cust1 , ps_ro_boid bo1 , ps_ro_boid bo11 , PS_RO_CUSTOMER cust2 , ps_ro_boid bo2 , ps_ro_boid bo22 WHERE cust2.capture_id = cust1.capture_id AND cust2.rbtnewacct = 'R' AND bo1.capture_id = cust1.capture_id AND bo11.capture_id = cust1.capture_id AND bo2.capture_id = cust2.capture_id AND bo22.capture_id = cust2.capture_id AND (bo1.uid20 = cust1.uid20f_r_bill AND bo2.uid20 = cust2.uid20f_r_bill) AND (bo11.uid20 = cust1.uid20f_r_billc AND bo22.uid20 = cust2.uid20f_r_billc) UNION SELECT DISTINCT h.capture_id , ' ' , hbo1.bo_id , 0 FROM PS_RO_CUSTOMER cust , ps_ro_boid bo1 , ps_ro_header h , ps_ro_boid hbo1 WHERE h.capture_id = cust.capture_id AND h.rbtnewacct = 'R' AND bo1.capture_id = cust.capture_id AND hbo1.capture_id = h.capture_id AND (bo1.uid20 = cust.uid20f_r_bill AND hbo1.uid20 = h.uid20f_r_bill) AND cust.uid20f_r_billc = ' ' AND h.uid20f_r_billc = ' ' UNION SELECT DISTINCT cust2.capture_id , cust2.uid20 , bo2.bo_id , 0 FROM PS_RO_CUSTOMER cust1 , ps_ro_boid bo1 , PS_RO_CUSTOMER cust2 , ps_ro_boid bo2 WHERE cust2.capture_id = cust1.capture_id AND cust2.rbtnewacct = 'R' AND bo1.capture_id = cust1.capture_id AND bo2.capture_id = cust2.capture_id AND (bo1.uid20 = cust1.uid20f_r_bill AND bo2.uid20 = cust2.uid20f_r_bill) AND cust1.uid20f_r_billc = ' ' AND cust2.uid20f_r_billc = ' '
|