title: What table a record came from and if more than one table
body: <p>I have 4 tables (<code>Table1</code> through <code>Table4</code>) and column <code>CODE</code> in each table. I use a <code>UNION ALL</code> to identify where they come from</p>
  
  <pre><code>select  distinct CODE, 'Table1'  from Table1 where TABLE1_EFF_STARt &gt;= '01/01/2014'
  union all
  select  distinct CODE, 'Table2' from Table2 where TABLE2_EFF_STARt &gt;= '01/01/2014'
  union all
  select  distinct CODE, 'Table3' from Table3 where TABLE3_EFF_STARt &gt;= '01/01/2014'
  union all
  select  distinct CODE, 'Table4' from Table4 where TABLE4_EFF_STARt &gt;= '01/01/2014' 
  </code></pre>
  
  <p>Sometimes the same <code>CODE</code> can be in more than one table, and I want to identify and return the result in a below table form. When code in more than one table I want to flag it as <code>Y</code> in the <code>Multisource</code> column.</p>
  
  <pre><code>CODE    Table1  Table2  Table3  Table4  Multisource
  
  12345   Y       N       N       N       N
  34233   Y       Y       N       N       Y
  45345   Y       N       N       N       N
  23417   Y       N       Y       N       Y
  45346   Y       N       N       N       Y
  </code></pre>