title: How to count values with different where clauses on the same column?
body: <p>I hate that I have to ask but I just cant handle it.</p>
  
  <p>I have this table <code>votes</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/d0917.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d0917.png" alt="enter image description here"></a></p>
  
  <p><code>type=1</code> is an upvote, <code>type=0</code> would be a downvote</p>
  
  <p>I want this output:</p>
  
  <pre><code>[
    {'video': 'best-of-mehrwert', 'upvote': 2, 'downvote': 0},
    {...}
  ]
  </code></pre>
  
  <p>I am using medoo:</p>
  
  <pre><code>&lt;?php
  $votes = $database-&gt;query(
    // 'SELECT COUNT(video) as votes, video FROM votes GROUP BY video, type'
    '
      SELECT video,COUNT(*) as counts
      FROM votes
      GROUP BY video,type;
  
    '
  )-&gt;fetchAll(PDO::FETCH_ASSOC);
  
  echo json_encode($votes);
  </code></pre>
  
  <p>which gives me</p>
  
  <pre><code>[{"video":"anlaesse","counts":"1"},{"video":"best-of-mehrwert","counts":"2"}]
  </code></pre>
  
  <p>How do I "add a column" like "upvotes" i.e. entries where type = 1 and the same with type = 0?</p>