title: SQL Query for Chart JS
body: <p>I have the a table like this.</p>
  
  <pre><code>| id  | question_id | option_id |
  ---------------------------------
  | 1   |         1   |         1 |
  | 1   |         1   |         2 |
  | 1   |         1   |         3 |
  | 1   |         1   |         2 |
  | 1   |         1   |         2 |
  | 1   |         1   |         6 |
  </code></pre>
  
  <p>How would I query for the result as follows?</p>
  
  <pre><code>[
    {'1' =&gt; 1},
    {'2' =&gt; 3},
    {'3' =&gt; 1},
    {'4' =&gt; 0},
    {'5' =&gt; 0},
    {'6' =&gt; 1},
  ]
  </code></pre>
  
  <p>Currently what I have is by looping the query from 1 to 6. Is there a way for me to query the counts for all possible value of option_id without knowing about the possible values (1 to 6)?</p>
  
  <pre><code>Select sum(case when option_id = 1 then 1 else 0 end) as "1" FROM fcs_answer WHERE question_id = 4;
  </code></pre>