title: MYSQL LEFT JOIN with GROUP BY
body: <p>:)
  I have 2 queries, and I need to join them, I need to compare the working time of employee depending on activity with total working time of company in the same activity in defined period</p>
  
  <p>First query is:</p>
  
  <pre><code>SELECT u.login,
         a.article, 
         p.p_article, 
         (SUM(p.p_going) + SUM(p.p_leaving) + SUM(p.p_working)) AS tottime
  FROM pos p,users u, articles a
  WHERE u.login = p.p_login
  AND REPLACE( u.login, '.', '_' ) = 'users_name'
  AND p.p_datum &gt;= '2013-04-09'
  AND p.p_datum &lt;= '2013-04-16'
  AND p.p_article = a.id
  GROUP BY a.article
  </code></pre>
  
  <p>And my second query is:</p>
  
  <pre><code>SELECT a.article, 
         p.p_article, 
         (SUM(p.p_going) + SUM(p.p_leaving) + SUM(p.p_working)) AS tottime
  FROM pos p, articles a
  WHERE p.p_datum &gt;= '2013-04-09'
  AND p.p_datum &lt;= '2013-04-16'
  AND p.p_article = a.id
  GROUP BY a.article
  </code></pre>
  
  <p>The first query returns me total working time of WORKER grouped by activites, for example:</p>
  
  <pre><code>u.login    a.article     p.p_article  tottime
  Ivan       Teambuilding    1          3,45
  Julie      Social_work     2          5,67
  </code></pre>
  
  <p>The second query returns me total working time of COMPANY grouped by activites, for example:</p>
  
  <pre><code>a.article     p.p_article  tottime
  Teambuilding    1         150
  Social_work     2         260
  </code></pre>
  
  <p>I want to have something like this, so I can compare the total time of worker per activity with total time of company working hours per activity in specific period:</p>
  
  <pre><code>u.login    a.article     p.p_article  tottime(worker)  tottime(company) 
  Ivan       Teambuilding    1          3,45              150  
  Julie      Social_work     2          5,67              260
  </code></pre>
  
  <p>In case of the NULL values I would like to use LEFT JOIN. I was searching for the solution for 3 hours, and everything I try is not working, so any help would be appreciated. </p>