title: Calculate Percentage in MySQL Query
body: <p>I am trying to produce a MySQL table that contains a column displaying the percentage corresponding to one count over another with the same grouping. Overall, I want to combine the following two queries into one that, instead of displaying a count, displays a percentage. Here are the two queries:</p>
  
  <pre><code>SELECT machine, COUNT(machine)
  FROM rtcdb.session
  WHERE project = "CSC032"
    AND (qc_gsr = 'green'
      AND qc_hr = 'green'
      AND qc_acz = 'green'
      AND qc_bre = 'green'
    )
  GROUP BY machine;
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>SELECT machine, COUNT(machine)
  FROM rtcdb.session
  WHERE project = "CSC032"
  GROUP BY machine;
  </code></pre>
  
  <p>There are scenarios where the first query will produce less rows than the second - this happens when there are machines that do not have any successes (greens) at all. How would I combine these queries into one that computes the percentage of all machines that are successes (essentially, a success rate), and displays this in its own column? </p>