代わりにユニオンを使用できます
SELECT u.circle_code, u.city,
u.msisdn AS subs_msisdn,
u.user_name || '' || u.last_name AS subs_name
FROM mtx_party u
WHERE msisdn LIKE :msisdn
AND u.user_id = mti.party_id
/*STATEMENT THAT EXCLUDES THIS RESULTS FROM THIS QUERY*/
AND mti.category_code = 'SUBS'
union
SELECT u1.circle_code, u1.city,
u1.msisdn AS ret_msisdn,
u1.user_name || '' || u1.last_name AS ret_name,
u2.user_name || '' || u2.last_name AS dist_name,
u2.msisdn AS dist_msisdn, ' ' AS dist_acc_no,
u1.agent_code
FROM users u1, users u2
WHERE msisdn LIKE :msisdn
AND u1.user_id = mti.party_id
AND u2.user_id = u1.parent_id
/*STATEMENT THAT EXLUDES RESULTS FROM THIS QUERY*/
AND mti.category_code <> 'SUBS'
または、次のことができます
select mti.*,
CASE WHEN mti.category_code = 'SUBS'
THEN sub1.circle_code
ELSE sub2.circle_code
END as circle_code,
CASE WHEN mti.category_code = 'SUBS'
THEN sub1.city
ELSE sub2.city
END as city,
CASE WHEN mti.category_code = 'SUBS'
THEN sub1.subs_msisdn
ELSE sub2.ret_msisdn
END as msisdn,
etc......
from table mti
left outer join (
SELECT u.user_id, u.circle_code, u.city,
u.msisdn AS subs_msisdn,
u.user_name || '' || u.last_name AS subs_name
FROM mtx_party u
WHERE msisdn LIKE :msisdn
/*STATEMENT THAT EXCLUDES THIS RESULTS FROM THIS QUERY*/
AND mti.category_code = 'SUBS'
) sub1 on sub1.user_id = mti.party_id
left outer join (
SELECT u1.user_id, u1.circle_code, u1.city,
u1.msisdn AS ret_msisdn,
u1.user_name || '' || u1.last_name AS ret_name,
u2.user_name || '' || u2.last_name AS dist_name,
u2.msisdn AS dist_msisdn, ' ' AS dist_acc_no,
u1.agent_code
FROM users u1, users u2
WHERE msisdn LIKE :msisdn
AND u2.user_id = u1.parent_id
/*STATEMENT THAT EXLUDES RESULTS FROM THIS QUERY*/
AND mti.category_code <> 'SUBS'
) sub2 on sub2.user_id = mti.party_id