title: SQL Counting the number of occurence based on a subject
body: <p>I find it hard to word what I am trying to achieve. I have a table that looks like this:</p>
  
  <pre><code>user char
  ---------
  a | x
  a | y
  a | z
  b | x
  b | x
  b | y
  c | y
  c | y
  c | z
  </code></pre>
  
  <p>How do I write a query that would return me the following result?</p>
  
  <pre><code>user x y z
  -------
  a |1|1|1|
  b |2|1|0|
  c |0|2|1|
  </code></pre>
  
  <p>the numbers represent the no of occurences of chars in the original table</p>
  
  <p>EDIT:
  The chars values are unknown hence the solution cannot be restricted to these values. Sorry for not mentioning it sooner. I am using Oracle DB but planning to use JPQL to construct the query.</p>