title: Count multiple CASE occurrences in SQL
body: <p>I'm looking for solution for the following issue:</p>
  
  <pre><code>SELECT CASE WHEN p.value LIKE '%foo%' THEN 'foos'
      WHEN p.value LIKE '%bar%' THEN 'bars'
      WHEN p.value LIKE '%bakar%' THEN 'bakars'
      ELSE p.value END as value,
  COUNT(*) as count FROM table_a p GROUP BY value
  </code></pre>
  
  <p>Values are something like:</p>
  
  <pre><code>foo, bar, foo and bar, bakar, bakarbar, foobar
  </code></pre>
  
  <p>Result of this query is:</p>
  
  <pre><code> value    count
   foos       3
   bars       2
   bakars     1
  </code></pre>
  
  <p>This code successfully counts occurrences, but the CASE stops at first match.
  Is there a way to do this?</p>
  
  <pre><code>value    count
   foos       3
   bars       4
   bakars     2
  </code></pre>