title: Creating new variable in SQL with case statements
body: <p>Beginners SQL question: How do I insert a new categorical variable into a table?</p>
  
  <p>After running the following code in Oracle SQL Developer:</p>
  
  <pre><code>create table test (
    memberid varchar(10),
    sex char(1),
    healthcost float(10)
    );
  
  insert into test (memberid, sex, healthcost)
  values ('A0003','M',25000);
  insert into test (memberid, sex, healthcost)
  values ('A0002','F',55000);
  insert into test (memberid, sex, healthcost)
  values ('A0001','M',10000);
  
  alter table test
  add healthcost_catg varchar(20);
  
  insert into test (healthcost_catg)
  select case when healthcost &gt; 20000 then '&gt; $20,000' as healthcost_catg
         else '&lt;= $20,000' as healthcost_catg
  end  
  from test
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>Error at Command Line : 18 Column : 54
  Error report -
  SQL Error: ORA-00905: missing keyword
  00905. 00000 -  "missing keyword"
  *Cause:    
  *Action:
  </code></pre>