title: Group by with union mysql select query
body: <pre><code>(SELECT COUNT(motorbike.`owner_id`) as count,owner.`name`,transport.`type` FROM transport,owner,motorbike WHERE transport.type='motobike'
  AND owner.`owner_id`=motorbike.`owner_id`
  AND transport.`type_id`=motorbike.`motorbike_id` GROUP BY motorbike.owner_id)
  UNION ALL
  (SELECT COUNT(car.`owner_id`) as count,owner.`name`,transport.`type` FROM transport,owner,car WHERE transport.type='car'
  AND owner.`owner_id`=car.`owner_id`
  AND transport.`type_id`=car.`car_id` GROUP BY car.`owner_id`)
  </code></pre>
  
  <p>The query above returns a result like this below,</p>
  
  <pre><code>count          name
  1              Linda
  2              Mary
  1              Steve
  1              Linda
  </code></pre>
  
  <p>This query is to count how many transport that owned by an owner. Linda have one car and one motorcycle,so the result should:</p>
  
  <pre><code>count          name
  2              Linda
  2              Mary
  1              Steve
  </code></pre>
  
  <p>I have tried this query,but return error:</p>
  
  <pre><code>(SELECT COUNT(motorbike.`owner_id`),owner.`name`,transport.`type` FROM transport,owner,motorbike WHERE transport.type='motobike'
  AND owner.`owner_id`=motorbike.`owner_id`
  AND transport.`type_id`=motorbike.`motorbike_id`)
  UNION ALL
  (SELECT COUNT(car.`owner_id`),owner.`name`,transport.`type` FROM transport,owner,car WHERE transport.type='car'
  AND owner.`owner_id`=car.`owner_id`
  AND transport.`type_id`=car.`car_id`)  GROUP BY motorbike.owner_id
  </code></pre>
  
  <p>Can anyone help me please?</p>