title: SQL query to return rows, starting with the latest, whose values sum to value in another table
body: <p>I have two tables, <code>Table1</code> has historical transactions and <code>Table2</code> has a field that stores the balance of those transactions for each account.</p>
  
  <p>I need a <code>SQL query</code> that will return the transactions in <code>Table1</code> for a specific account, starting from the latest transaction that sum up to the current balance in <code>Table2</code>. </p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p><strong>Table1</strong></p>
  
  <blockquote>
    <p>UniqID .  AcctNum  . TranType . TranDate . TranAmt<br/> 
    1 . . . . . 1001123 . . . . A . . . . . 11/1/13 . . . . 100<br/> 
    2 . . . . . 1010877 . . . . B . . . . . 12/2/13 . . . . . 10<br/> 
    7 . . . . . 1010877 . . . . C . . . . . 12/2/13 . . . . . 22<br/> 
    10. . . .. 1001123 . . . . A . . . . . 12/2/14 . . . .-100<br/> 
    11. . . .. 1001123 . . . . B . . . . . 12/6/13 . . . . 145<br/> 
    12. . . .. 1003699 . . . . A . . . . . 12/8/13 . . . . 250<br/> 
    13. . . .. 1001123 . . . . B . . . . . 1/2/14 . . . . . 145<br/> 
    14. . . .    .1003699    . . . . C . . . . . 1/4/14 . . . . . 110<br/> 
    15. . . .    .1003699 . . . . C . . . . . 1/4/14 . . . . .-110<br/> 
    19. . . .    .1003699 . . . . B . . . . . 1/8/14 . . . . . . 25<br/> 
    21. . . .    .1001123 . . . . B . . . . . 1/2/14 . . . . . . 80<br/> 
    22. . . .    .1001123 . . . . B . . . . . 1/8/14 . . . . . . 45<br/> 
    26. . . .    .1001123 . . . . A . . . . . 1/21/14 . . . .-145<br/> </p>
  </blockquote>
  
  <p><strong>Table2</strong></p>
  
  <blockquote>
    <p>AcctNum . TranBal<br/>
    1001123 . . . . 270<br/>
    1003699 . . . . 275<br/>
    1010877 . . . . . 32<br/>
    <br/></p>
  </blockquote>
  
  <p>Expected Result for account 1001123</p>
  
  <blockquote>
    <p>UniqID .  AcctNum  . TranType . TranDate . TranAmt<br/> 
    11. . . .. 1001123 . . . . B . . . . . 12/6/13 . . . . 145<br/> 
    13. . . .. 1001123 . . . . B . . . . . 1/2/14 . . . . . 145<br/> 
    21. . . .    .1001123 . . . . B . . . . . 1/2/14 . . . . . . 80<br/> 
    22. . . .    .1001123 . . . . B . . . . . 1/8/14 . . . . . . 45<br/> 
    26. . . .    .1001123 . . . . A . . . . . 1/21/14 . . . .-145<br/> </p>
  </blockquote>