title: update columns in a table based on row values from another table
body: <p>I have a table TABLE1 with data in this format:</p>
  
  <pre>
  
      id     text       pct
      --     ---      -----
      1        AA        5
      1        BB        3
      1        CC        16
      2        BB        7
      3        CC        13
  
  </pre>
  
  <p>And another table TABLE2:</p>
  
  <pre>
  
      id     columnAA      columnBB     columnCC
      --     -------       -------      --------
      1        0             0             0
      2        0             0             0
      3        0             0             0
  
  
  </pre>
  
  <p>I would like to update columns in table2 so my result will look like:</p>
  
  <pre>
  
      id     columnAA      columnBB     columnCC 
      --     -------       -------      -------- 
      1        5              3             16 
      2        0              7              0 
      3        0              0             13 
  
  </pre>
  
  <p>I tried with this code but it's not really working. It only updates one column!</p>
  
  <pre>
      update a
        set columnAA = case when b.text = 'AA' then b.pct else columnAA end
       ,set columnBB = case when b.text = 'BB' then b.pct else columnBB end
       ,set columnCC = case when b.text = 'CC' then b.pct else columnCC end
      from table2 a
      join table1 b
        on a.id = b.id
  </pre>