title: MySQL - Subquery returns more than 1 row
body: <p>Firstly, here is an example of a table that I'm trying to manipulate :</p>
  
  <pre><code>##################################
  #             TABLE_A            #
  ##################################
  +----------+----------+----------+
  |    ID    | COLUMN_A | COLUMN_B |
  +----------+----------+----------+
  |     1    |    24    |     1    |
  |     2    |    53    |     1    |
  |     3    |    12    |     1    |
  |     4    |    87    |     2    |
  |     5    |    63    |     2    |
  |     6    |    55    |     3    |
  |     7    |    39    |     3    |
  |     8    |    47    |     3    |
  |     9    |    85    |     3    |
  +----------+----------+----------+
  </code></pre>
  
  <p>I want to calculate the percentage of each values of the column_a when the column_b has the same value.</p>
  
  <p>For example, when <strong>column_b = 1</strong>, 24+53+12=89 so we will get the following percentages : </p>
  
  <ul>
  <li>24 : 27%</li>
  <li>53 : 60%</li>
  <li>12 : 13%</li>
  </ul>
  
  <p>This is working when I use "WHERE" to indicate the value of the column_b as you can see with this request:</p>
  
  <pre><code>SELECT ROUND(
      (column_a*100) / (SELECT SUM(column_a) 
                        FROM TABLE_A 
                        WHERE column_b=1)
              ) AS RESULT 
  FROM TABLE_A 
  where column_b=1;
  
  +--------+
  | RESULT |
  +--------+
  |   27   |
  |   60   |
  |   13   |
  +--------+
  </code></pre>
  
  <p>But, when I try to calculate all percentages for each value of the column_b, it's still not working.</p>
  
  <p>I have tried to do this with a 'GROUP BY' but the error "Subquery returns more than 1 row" occured  :</p>
  
  <pre><code>SELECT ROUND(
          (column_a*100) / (SELECT SUM(column_a) 
                            FROM TABLE_A 
                            GROUP BY column_b)
          ) AS RESULT 
  FROM TABLE_A;
  </code></pre>
  
  <p>I understand why I have this error because the second SELECT returns 3 values and it's not possible to divide these successively. So, how can I do what I want please ?</p>