title: PostgreSQL create a new column with values conditioned on other columns
body: <p>I use PostgreSQL 9.1.2 and I have a basic table as below, where I have the Survival status of an entry as a boolean  <code>(Survival)</code> and also in number of days <code>(Survival(Days))</code>. </p>
  
  <p>I have manually added a new column named <code>1-yr Survival</code> and now I want to fill in the values of this column for each entry in the table, conditioned on that entry's <code>Survival</code> and  <code>Survival (Days)</code> column values. Once , completed the database table would look something like this:</p>
  
  <pre><code>Survival    Survival(Days)    1-yr Survival
  ----------  --------------    -------------
  Dead            200                NO
  Alive            -                 YES
  Dead            1200               YES
  </code></pre>
  
  <p>The pseudo code to input the conditioned values of <code>1-yr Survival</code> would be something like:</p>
  
  <pre><code>ALTER TABLE mytable ADD COLUMN "1-yr Survival" text
  for each row
  if ("Survival" = Dead &amp; "Survival(Days)" &lt; 365) then Update "1-yr Survival" = NO
  else Update "1-yr Survival" = YES
  end 
  </code></pre>
  
  <p>I believe this is a basic operation however I failed to find the postgresql syntax to execute it. Some search results return "adding a trigger", but I am not sure that is what I neeed. I think my situation here is a lot simpler. Any help/advice would be greatly appreciated.</p>