title: SQL create a temp table or update table field?
body: <p>I have created a new table from various joined tables with some logic inside of it to determine certain process time based on two time stamps like the following.</p>
  
  <pre><code>select  t1.date_created,
          t1.date_due,
          (t1.date_closed - t1.date_created)*86400 as due_time
          t2.date_created.
          t2.date_closed,
          (t2.date_closed - t2.date_created)*86400 as process_time
  from table1 as t1
  inner join table2 on t1.ID = T2.table1ID
  </code></pre>
  
  <p>Bear in mind I have made several more joins (just an example).
  Now I wish to determine if the t2 process time is bigger than t1 time like the following.</p>
  
  <pre><code>case   
    when t1.due_time &gt; t2.process_time
    then 1
    else 0
  end as ind_within_due_time
  </code></pre>
  
  <p>Now my question is what the best practice would be. </p>
  
  <p>A. To create a temp table with the entire join logic. then create a new table to determine to ind_within_due_time and drop the old table.</p>
  
  <p>or B. create a table with the join logic and create a empty column in the table to then write an update script to allocate the value afterwards?</p>