title: oracle - sql full outer join on three select statements
body: <p>I want to select values from three tables.  Each table has an buyer_entity_id column.</p>
  
  <p>I've come up with the syntax to do an outer join on two of the tables, but how to add the third table is eluding me. </p>
  
  <p>Here's the statement for the two table join which works exactly how I want it to work:</p>
  
  <pre><code>select * from (select  b.buyer_entity_id, count(distinct(a.row_id)) as imps 
  from imps a, anl_line b
  where b.line_item_id=a.buyer_line_id 
  and a.entity_id=3
  group by b.buyer_entity_id
  order by b.buyer_entity_id) tab1
  full outer join (select b.buyer_entity_id, count(distinct(a.row_id)) as clicks 
  from clicks a, anl_line b 
  where a.buyer_line_id=b.line_item_id 
  and a.entity_id=3
  group by b.buyer_entity_id 
  order by b.buyer_entity_id) tab2
  on tab1.buyer_entity_id = tab2.buyer_entity_id;
  </code></pre>
  
  <p>The third table would have an identical select statement and would also be joined on the buyer_entity_id value as well.  However, when I add the third select statement I'm getting a "missing keyword" error.  Below is my three way full outer join statement:</p>
  
  <pre><code>select * from ((select  b.buyer_entity_id, count(distinct(a.row_id)) as imps 
  from imps_table a, line_table b
  where b.line_item_id=a.buyer_line_id 
  and a.entity_id=3
  group by b.buyer_entity_id
  order by b.buyer_entity_id) tab1
  full outer join (select b.buyer_entity_id, count(distinct(a.row_id)) as clicks 
  from clicks_table a, line_table b 
  where a.buyer_line_id=b.line_item_id 
  and a.entity_id=3
  group by b.buyer_entity_id 
  order by b.buyer_entity_id) tab2)
  outer join (select  b.buyer_entity_id, count(distinct(a.row_id)) as vers 
  from vers_table a, line_table b
  where b.line_item_id=a.buyer_line_id 
  and a.entity_id=3
  group by b.buyer_entity_id
  order by  b.buyer_entity_id) tab3
  on tab1.buyer_entity_id = tab2.buyer_entity_id and tab2.buyer_entity_id=tab3.buyer_entity_id;
  </code></pre>