title: Oracle sql query avoid UNION clause?
body: <p>I am new to SQL. i am using Oracle10g. i have below query. it has 3 parts and am doing UNION of all three parts. 
      But in every query most of the logic is common except join table. is it possible to avoid UNION and place everything in a single block?</p>
  
  <pre><code>    SELECT DISTINCT e.some_id
           FROM
               main_table e,
               main_table_join_one x     //only change
               where  e.some_id = x.some_id(+)
               and (x.status in('A','I') or x.status is null)
               and e.code='XYZ' and e.second_code in('XYZ','ABC')
  
               UNION
  
      SELECT DISTINCT ef.some_id
           FROM
               main_table ef,
               main_table_join_two xf  //only change
               where  ef.some_id = xf.some_id(+)
               and (xf.status in('A','I') or xf.status is null)
               and ef.code='XYZ' and ef.second_code in('XYZ','ABC')
  
               UNION
  
      SELECT DISTINCT eff.some_id
           FROM
               main_table eff,
               main_table_join_three xff   //only change
               where  eff.some_id = xff.some_id(+)
               and (xff.status in('A','I') or xff.status is null)
               and eff.code='XYZ' and eff.second_code in('XYZ','ABC')
  </code></pre>
  
  <p>Thanks!</p>