title: SQL Replace blank value in case statement
body: <p>I have two tables:</p>
  
  <p>Student (ks2en, ks2ma, ks2av)</p>
  
  <p>Subject (name)</p>
  
  <p>I have the following conditional statement which depending on the subject lists the values in the student columns. These are then subsequently grouped by their respective student column.</p>
  
  <p>In any combination I would like to replace '' blank values in the result set with 'No KS2'.</p>
  
  <p>Here is my case statement which conditionally selects the appropriate column from the student table base on the subject name in the subject table.</p>
  
  <pre><code>   CASE 
        WHEN COALESCE(Name, '') = 'English' THEN
          [Ks2en]
        WHEN COALESCE(Name, '') = 'Mathematics' THEN
          [Ks2ma]
        ELSE
          [Ks2av]
     END AS KS2
  </code></pre>
  
  <p>Example data:</p>
  
  <pre><code>ks2en
  2a
  2a
  3a
  4c
  
  5a
  3a
  2a
  
  1c
  </code></pre>
  
  <p>When the subject name is 'English' then the following results are displayed:</p>
  
  <pre><code>KS2
  No KS2
  1c
  2a
  3a
  4c
  5a
  </code></pre>
  
  <p>Just to be clear, don't worry about ordering, grouping or the conditional element of the statement as I have got these all working. It's just replacing blank values with 'No KS2' so that it displays as one of the groups of values in the results set as above.</p>