title: Adding a new column in SQL which calculates value from other columns
body: <p>I was trying to create a new column in SQL which has calculated values from other columns in the same table. </p>
  
  <p>Please see the case below</p>
  
  <pre><code>col1 col2
  A    1   
  A    2
  B    1
  B    2
  B    3
  </code></pre>
  
  <p>I need to create a new column 'col3' that finds the max of col2 grouped by col1. So the result i want is</p>
  
  <pre><code>col1 col2 col3
  A    1    2   
  A    2    2
  B    1    3
  B    2    3
  B    3    3
  </code></pre>
  
  <p>I would like to know if a query can be something along the below lines</p>
  
  <pre><code>ALTER TABLE table1 ADD col3 AS (SELECT max(col2) GROUPBY col1)
  </code></pre>