title: Using CASE statement in SUM() In Stored Procedure
body: <p>Here is my code:</p>
  
  <pre><code>BEGIN
  
      SELECT SUM(
         CASE WHEN first_name &gt; '' THEN 1 ELSE 0 END AS a 
         CASE WHEN last_name &gt; '' THEN 1 ELSE 0 END AS b,             
         CASE WHEN country &gt; '' THEN 1 ELSE 0 END AS c, 
         CASE WHEN state &gt; '' THEN 1 ELSE 0 END AS d, 
         CASE WHEN city &gt; '' THEN 1 ELSE 0 END AS e)
      AS total
      FROM employee_profile     
      WHERE id = user_id_in;
  
  END
  </code></pre>
  
  <p>This generates the following error:</p>
  
  <blockquote>
    <p>you have an error in your SQL syntax check the manual that corresponds to your MySQL server version for the right syntax to use near xxx error for the first line.</p>
  </blockquote>
  
  <p>Can anyone help with the correct syntax for this, please?</p>
  
  <p>MySQL Server version: 5.5.8</p>