title: SELECT two variables in SQL, one with a WHERE
body: <p>I have a table with votes: <strong>id</strong> is the person who voted, <strong>vote</strong> = 1 is the fact that he participated, and <strong>num</strong> is the number of vote.</p>
  
  <p>I would like to select two variables from the same query, and one <code>WHERE</code> conditions would apply to only one variable. These two variables should be <code>GROUP BY</code> the same date, using <code>YEAR()</code> and <code>MONTH()</code>.</p>
  
  <p>This is a sample of the initial table:</p>
  
  <pre><code>+----+------------+------+-----+
  | id |    date    | vote | num |
  +----+------------+------+-----+
  |  1 | 2018-01-25 |    1 |   1 |
  |  3 | 2018-01-25 |    1 |   1 |
  |  4 | 2018-01-25 |    1 |   1 |
  |  5 | 2018-01-25 |    1 |   1 |
  |  1 | 2018-01-25 |    1 |   1 |
  |  3 | 2018-01-25 |    1 |   1 |
  |  4 | 2018-01-25 |    1 |   1 |
  |  1 | 2017-12-25 |    1 |   2 |
  |  2 | 2017-12-25 |    1 |   2 |
  |  5 | 2017-12-25 |    1 |   2 |
  |  2 | 2017-11-20 |    1 |   3 |
  |  3 | 2017-11-20 |    1 |   3 |
  |  5 | 2017-11-20 |    1 |   3 |
  |  6 | 2017-11-20 |    1 |   3 |
  |  7 | 2017-11-20 |    1 |   3 |
  +----+------------+------+-----+
  </code></pre>
  
  <p>I would like to have, in the same query, the <code>SUM()</code> of <strong>vote</strong> by month and by year and <code>WHERE id = 1</code> for instance; and the <code>COUNT(DISTINCT(())</code> of the votes (<strong>num</strong>), by month and by year. </p>
  
  <p>The idea would be to have, for every month, the number of time a person (<strong>id</strong>) have voted and the number of votes there have been. Like this example, if we select <strong>id</strong> = 2.</p>
  
  <pre><code>+----+-------+------+---------------+-------+
  | id | month | year | participation | total |
  +----+-------+------+---------------+-------+
  |  2 |     1 | 2018 |             0 |     1 |
  |  2 |    12 | 2017 |             0 |     1 |
  |  2 |    11 | 2017 |             1 |     1 |
  +----+-------+------+---------------+-------+
  </code></pre>
  
  <p>All the queries that I have tried are not good.</p>