title: Query to Read records from three TABLES
body: <p>I need a SQL query to read records from three TABLES say TABLE A,TABLE B,TABLE C. Each table has ID and creationdatetime column as common between them.</p>
  
  <p>I can insert data from front end </p>
  
  <ol>
  <li>either in TABLE A </li>
  <li>or in TABLE B </li>
  <li>or in TABLE C </li>
  <li>or TABLE A and TABLE B </li>
  <li>or TABLE B and TABLE C </li>
  <li>or TABLE C and TABLE A </li>
  <li>or TABLE A and TABLE B and TABLE C.</li>
  </ol>
  
  <p>And also data returned from the query should be sorted in descending order based on creationdatetime column of the records and also there should not be any duplicates.</p>
  
  <p>Please refer:</p>
  
  <pre><code>TABLE A: ID   creationdatetime 
  
  TABLE B: ID   creationdatetime
  
  TABLE C: ID   creationdatetime
  </code></pre>
  
  <p><strong>Scenario:-1</strong></p>
  
  <pre><code>TABLEA
  ID    Creationdatetime
  1     2014-05-28 11.00
  
  TABLEB
  ID    Creationdatetime
  1     2014-05-28 11.00
  
  TABLEC
  ID    Creationdatetime
  1     2014-05-28 11.00
  </code></pre>
  
  <p><strong>Scenario:-2</strong></p>
  
  <pre><code>TABLEA
  ID    Creationdatetime
  1     2014-05-28 11.00
  
  TABLEB (No Data)
  ID    Creationdatetime
  
  TABLEC
  ID    Creationdatetime
  1     2014-05-28 11.00
  </code></pre>
  
  <p><strong>Scenario:-3</strong></p>
  
  <pre><code>TABLEA
  ID    Creationdatetime
  1     2014-05-28 11.00
  
  TABLEB (No Data)
  ID    Creationdatetime
  
  TABLEC (No DATA)
  ID    Creationdatetime
  </code></pre>
  
  <p><strong>Scenario:-4</strong></p>
  
  <pre><code>TABLEA
  ID    Creationdatetime
  1     2014-05-28 11.00
  
  TABLEB
  ID    Creationdatetime
  1     2014-05-28 12.00
  
  TABLEC
  ID    Creationdatetime
  1     2014-05-28 13.00
  </code></pre>
  
  <p>Just to add from the four scenario's Which I have mentioned above .I expect a query which should return:</p>
  
  <p>Scenario:-1,Scenario:-2,Scenario:-3= one record and 
  Scenario:-4= 3 records</p>
  
  <p>This is a sample code which I am trying to join two tables:</p>
  
  <pre><code>select * from TABLEA, TABLEB
  where TABLEA.ID=9205920588298715136
  group by TABLEB.creationdatetime
  order by TABLEB.creationdatetime desc
  </code></pre>