title: Adding the results of CASE statements
body: <p>I have the following Oracle SQL query.  Given a given name and surname, it finds all records with One name and the initial of the other, in either order.  I have created the <code>score</code> column to place likely matches at the top of the results set.</p>
  
  <pre><code>SELECT
    surname,
    givenname,
    (CASE WHEN surname = 'Smith' THEN 2 ELSE 0)
      + (CASE WHEN givenname = 'John' THEN 1 ELSE 0)
      AS score
  FROM person
  WHERE (surname = 'Smith' AND givenname LIKE 'J%')
    OR  (surname LIKE 'S%' AND givenname = 'John')
    OR  (surname = 'John' AND givenname LIKE 'S%')
    OR  (surname LIKE 'J%' AND givenname = 'Smith')
  ORDER BY
    score DESC,
    surname ASC,
    givenname ASC;
  </code></pre>
  
  <p>The problem is the <code>score</code> is giving an error at the location of the <code>+</code>.  The IDE reports:</p>
  
  <blockquote>
    <p>Syntax error, expected:<br>
    /<br>
    *<br>
    |  </p>
  </blockquote>
  
  <p>And execution reports:</p>
  
  <blockquote>
    <p>SQL Error: ORA-00905: missing keyword</p>
  </blockquote>
  
  <p>What am I doing wrong?  Is there a better way to calculate the score?</p>