title: case issue in sql query to generate report
body: <p>I have a table like this:</p>
  
  <pre><code>leave_id  applicant  from_date   to_date    type   status
  1             a       2/7/2014   5/7/2014  Annual  Approve
  2           Basudev   2/7/2014   5/7/2014  Annual  Approve
  3           Basudev   2/7/2014   5/7/2014  Casual  Approve
  4           Basudev   2/7/2014   5/7/2014  Sick    Approve
  5             a       2/7/2014   5/7/2014  Casual  Approve
  6             a       2/7/2014   5/7/2014  Sick    Approve
  </code></pre>
  
  <p>I want a report like this:</p>
  
  <pre><code>applicant  annual  casual  sick
     a         2       4      6
  Basudev      1       4  
  </code></pre>
  
  <p>I am using this query</p>
  
  <pre><code>select a.applicant,
         case when a.type='Annual' 
           Then (DATEDIFF(to_date,from_date))+1 
           Else '' 
         End as Annual_consume,
         case when a.type='Casual' 
           Then (DATEDIFF(to_date,from_date))+1 
           Else '' 
         End as Casual_consume,
         case when a.type='Sick' 
           Then (DATEDIFF(to_date,from_date))+1 
           Else '' 
         End as Sick_consume 
  from leaves a 
  order by applicant
  </code></pre>
  
  <p>But it is showing data like this:</p>
  
  <pre><code>applicant  annual  casual  sick
     a         2    
     a                 4
     a                        6
  Basudev              2
  Basudev                     3  
  </code></pre>
  
  <p>Please help to fix this issue.</p>