title: Merge three tables in Select query by rule 3, 2, 1 records from each table
body: <p>Merge three tables in a <code>Select</code> query by rule 3, 2, 1 records from each table as follows:</p>
  
  <ul>
  <li>TableA: ID, FieldA, FieldB, FieldC,....</li>
  <li>TableB: ID, FieldA, FieldB, FieldC,....</li>
  <li><p>TableC: ID, FieldA, FieldB, FieldC,....</p></li>
  <li><p><code>ID</code> : auto number in each table</p></li>
  <li><code>FieldA</code> will be unique in all three tables.</li>
  </ul>
  
  <p>I am looking for a <code>Select</code> query to merge three tables as follows:</p>
  
  <ul>
  <li>TOP three records from <code>TableA</code> sorted by ID</li>
  <li>TOP two records from <code>TableB</code> sorted by ID</li>
  <li>TOP 1 record from <code>TableC</code> sorted by ID</li>
  </ul>
  
  <p>Repeat this until select all records from all three tables.</p>
  
  <p>If some table has fewer records or does not meet the criteria, ignore that and continue with others.</p>
  
  <p>My attempt:</p>
  
  <p>I did it totally through programming way, like cursors and <code>If</code> conditions inside a SQL Server stored procedure.</p>
  
  <p>It makes delay.</p>