title: Dividing a sum value into multiple rows due to field length constraint
body: <p>I am migrating financial data from a very large table (100 million+ of rows) by summarizing the amount and insert them into summary table. I ran into problem when the summary amount (3 billions) is larger than what the field in the summary table can hold (can only hold up to 999 millions.)  Changing the field size is not an option as it requires a change process.</p>
  
  <p>The only option I have is to divide the amount (the one that breach the size limit) into smaller ones so it can be inserted into the table.</p>
  
  <p>I came across this <a href="https://stackoverflow.com/questions/11589821/sql-i-need-to-divide-a-total-value-into-multiple-rows-in-another-table">SQL - I need to divide a total value into multiple rows in another table</a> which is similar except the number of rows I need to insert is dynamic.</p>
  
  <p>For simplicity, this is how the source table might look like</p>
  
  <p>account_table</p>
  
  <pre><code>acct_num   |      amt
  -------------------------------
     101         125.00
     101         550.00
     101         650.00
     101         375.00
     101         475.00
     102          15.00
     103         325.00
     103         875.00
     104         200.00
     104         275.00
  </code></pre>
  
  <p>The summary records are as follows<p></p>
  
  <pre><code>select acct_num, sum(amt) 
  from account_table
  group by acct_num
  </code></pre>
  
  <p>Account Summary</p>
  
  <pre><code>acct_num   |      amt
  -------------------------------
     101        2175.00
     102          15.00
     103        1200.00
     104         475.00
  </code></pre> 
  
  <p>Assuming the maximum value in the destination table is 1000.00, the expected output will be </p>
  
  <p>summary_table</p>
  
  <pre><code>acct_num   |      amt
  -------------------------------
     101        1000.00
     101        1000.00
     101         175.00
     102          15.00
     103        1000.00
     103         200.00
     104         475.00
  </code></pre>
  
  <p>How do I create a query to get the expected result?  Thanks in advance.</p>