title: Selecting the second column in a complex mysql query
body: <p>I'm trying to create a query for reporting purposes and I'm failing when i try to select the date (second column) from multiple joins (selects).</p>
  
  <p>The query is something like this:</p>
  
  <pre><code>    SELECT a.Name, COALESCE(a.CustomerFaxes,0) AS 'CustomerFaxes', COALESCE(b.PoliceFaxes,0) AS 'PoliceFaxes', COALESCE(c.CustomerWebposts,0)AS 'CustomerWebposts', COALESCE(d.PoliceWebposts,0) AS 'PoliceWebposts', COALESCE(e.Letters,0) AS 'Letters'
  FROM jobs j
  
  LEFT JOIN (SELECT ...
      GROUP BY 1,2) a ON ...
  LEFT JOIN (SELECT ...
      GROUP BY 1,2) b ON ...
  LEFT JOIN (SELECT ...
      GROUP BY 1,2) c ON ...
  LEFT JOIN (SELECT ...
      GROUP BY 1,2) d ON ...
  LEFT JOIN (SELECT ...
      GROUP BY 1,2) e ON ..
  JOIN table cu ON ...
  JOIN table2 a ON ...
  WHERE j.UserID IN (1,2,3,4,5,6,7,8,9)
  AND j.receivedontime BETWEEN UNIX_TIMESTAMP (20150302) AND UNIX_TIMESTAMP (20150310)
  GROUP BY 1;
  </code></pre>
  
  <p>This results in something like</p>
  
  <p>User CustomerFaxes PoliceFaxes CustomerWebposts PoliceWebposts Letters</p>
  
  <p>There are a lot of conditions in between. All sub queries have the second value as a date, i want to select it and group by it.
  Any of you know a way?  </p>