SELECT *
FROM
(
SELECT A_WEBC_URL AS FILE_LOCATION
FROM BATELCO_BILLS_S
WHERE BTL_BILL_I_NUMBER = :B2 AND BTL_BILL_I_ACC_NUMBER = '0' || :B1
UNION
SELECT A_WEBC_URL AS FILE_LOCATION
FROM BATELCO_BILLS_S
WHERE BTL_BILL_I_NUMBER = :B2 AND (BTL_BILL_I_PROFILE_ID = :B1 OR
BTL_BILL_I_PHONE_NUMBER = :B3 )
UNION
SELECT A_WEBC_URL AS SS
FROM BATELCO_BILLS_S BILLS
WHERE BILLS.BTL_BILL_I_PROFILE_ID = :B1 OR
BTL_BILL_I_ACC_NUMBER = '0' || :B1 AND
BILLS.BTL_BILL_I_NUMBER = :B2
)
WHERE ROWNUM = 1
The above query taking time to consume.Please help to optimize the code so that we can fetch the results easily.