title: Generate incremental sequence number in teradata
body: <p>I have a scenario that there will be 2 tables.</p>
  
  <ol>
  <li><p>scratch.data_table</p></li>
  <li><p>scratch.temp_table</p></li>
  </ol>
  
  <p>scratch.data_table will have one of the field as sequence_id in incremental way like 4000,4001,4002 </p>
  
  <p>Other table   scratch.temp_table will have other columns same as scratch.data_table  but except sequence_id column</p>
  
  <p><code>scratch.temp_table</code> will have 5 records and I want to take <code>max</code> of <code>sequence_id</code> from <code>scratch.data_table</code> i.e 4002</p>
  
  <p>and insert it into the same table scratch.data_table from 5 records of scratch.temp_table</p>
  
  <p>Result should be like:</p>
  
  <pre><code>4000 | a | b | c
  4001 | x | y | z
  4002 | s | t | d
  4003 | d | t | f   --&gt; d|t|f is the records from scratch.temp_table and 4003 is the incremental value
  4004 | d | g | h
  4005 | g | t | h
  4006 | y | u | i
  4007 | y | y | t
  </code></pre>