title: Combine subselect
body: <p>I have to rewrite a query written for mysql5 to mysql4.0 which doesn't support sub select I have a query like this :</p>
  
  <pre><code>select a,
         c,
         (select count(*) from A) as e 
            from (select b, sum(e) as a 
                    from B 
                   where h = "foo" 
                group by b) TABLEB,
         (select sum(d),
                 count(*) as c 
            from C 
           where d = "bar") TABLEC
  </code></pre>
  
  <p>I try to merge TABLEA and TABLE B in one request but sum() results are not correct ( sum(e) values become sum(e) multiplied by the number of rows of TABLEC)</p>
  
  <p>All the grouped values become a multiple of the real values (depending on rows number).</p>
  
  <p>Is is possible to transform this query into only one query for mysql 4.0 or will I have to split it into 3 query ?</p>