title: I scratch my head with UNION ALL
body: <p>I am not an SQL query wizard at all, and here is my problem:</p>
  
  <p>I have those 3 separate querys that works very well and each one gives me a nice looking frame with results on my website.</p>
  
  <pre><code>SELECT   arretsautressb AS Raison, SUM(minutesarrets) AS Minutes 
  FROM     rapport_production_salles_blanches_2_repeat
  GROUP BY Raison 
  ORDER BY Minutes DESC
  
  SELECT   redresseuseminutesarrets AS Raison, SUM(minutesarretsredresseuse) AS Minutes 
  FROM     rapport_production_salles_blanches_3_repeat
  GROUP BY Raison 
  ORDER BY Minutes DESC
  
  SELECT   raisonarretsconvoyeurair AS Raison, SUM(minutesarretsconvoyeurair) AS Minutes 
  FROM     rapport_production_salles_blanches_4_repeat
  GROUP BY Raison 
  ORDER BY Minutes DESC
  </code></pre>
  
  <p>So everything is fine with those 3 results...the Raison column in my table return all the rows and the Minutes query SUM all rows Group by Raison...
  but i would like to merge those querys so it would give me only 1 big table with the results,instead on 3 tables.</p>
  
  <p>But no matter how i try to format my UNION ALL code, what i get is 1 result only from each Raison query (so it takes only 1 row in sql table), instead of all the rows when they are separated. but the Minutes query is doing fine calculating the SUM of all the rows. </p>
  
  <p>It would be cool if someone would just show me how to do it...cause i have been reading documentation for a couple of hours, and i am still stuck on this one.</p>
  
  <p>This is what i tried so far, no error, but only 1 row of Raison is taken from sql table, instead of all rows:</p>
  
  <pre><code>SELECT * 
  FROM ( (SELECT arretsautressb AS Raison, 
                 SUM(minutesarrets) AS Minutes 
          FROM   rapport_production_salles_blanches_2_repeat t1)
        UNION ALL
         (SELECT redresseuseminutesarrets AS Raison,
                 SUM(minutesarretsredresseuse) AS Minutes 
          FROM   rapport_production_salles_blanches_3_repeat t2)
        UNION ALL
         (SELECT  raisonarretsconvoyeurair AS Raison,
                  SUM(minutesarretsconvoyeurair) AS Minutes 
          FROM    rapport_production_salles_blanches_4_repeat t3)
       ) AS t123
  GROUP BY Raison 
  ORDER BY Minutes DESC
  </code></pre>
  
  <p>This is what i get from my UNION ALL query:</p>
  
  <p><a href="https://i.stack.imgur.com/zAk7K.png" rel="nofollow noreferrer">UNION ALL</a></p>
  
  <p>But this is what i get from 3 separated querys:</p>
  
  <p><a href="https://i.stack.imgur.com/QQz75.png" rel="nofollow noreferrer">3 querys</a></p>