title: How to add a new column with existing and new rows to a table?
body: <p>I have a table that I created with a unique key and each other column representing one day of December 2014 (eg named D20141226 for data from 26/12/2014). So the table consists of 32 columns (key + 31 days). These daily columns are indicating that a customer had a transaction on that specific day or no transaction is indicated by a 0.</p>
  
  <p>Now I want to execute the same query on a daily basis, producing a list of unique keys that had a transaction on that specific day. I used this easy script:</p>
  
  <pre><code>CREATE TABLE C01012015 AS
  SELECT DISTINCT CALLING_ISDN AS A_PARTY
  FROM CDRICC_012015
  WHERE CALL_STA_TIME ::date = '2015-01-01'
  </code></pre>
  
  <p>Now my question is, how can I add the content of the new daily table to the existing table with the 31 days, making it effectively a table with 32 days of data (and then continue to do so on a daily basis to store up to 360 days of data)?</p>
  
  <p>Please note that new customer are doing transactions every day hence there will unique keys in the daily table that aren't in the big table holding all the previous days.</p>
  
  <p>It would be ideal if those new rows would automatically get a 0 instead of a NULL but I can work around it if it gets a NULL value (not sure how to make sure it gets a 0 instead).</p>
  
  <p>I thought that a FULL OUTER JOIN would be the solution but that would mean that I have to list all variables in the select statement, which becomes quite large as I add one more column each day. Is there a more elegant way to do this?</p>
  
  <p>Or is SQL just not suited to this and a programming language like eg R would be much better at this?</p>