title: how to group by with a sql subqueries
body: <p>I can't think clearly at the moment, I want to return counts by station_id, an example of output would be:</p>
  
  <p>station 1 has 3 fb post, 6 linkedin posts, 5 email posts
  station 2 has 3 fb post, 6 linkedin posts, 5 email posts</p>
  
  <p>So I need to group by the station id, my table structure is </p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `posts` (
    `post_id` bigint(11) NOT NULL auto_increment,
    `station_id` varchar(25) NOT NULL,
    `user_id` varchar(25) NOT NULL,
    `dated` datetime NOT NULL,
    `type` enum('fb','linkedin','email') NOT NULL,
    PRIMARY KEY  (`post_id`)
  ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=x ;
  </code></pre>
  
  <p>The query I have so far is returning station 0 as having 2 linkedin posts when it has one (2 in the db tho)</p>
  
  <pre><code>SELECT Station_id, (select count(*) FROM posts WHERE type = 'linkedin') AS linkedin_count, (select count(*) FROM posts WHERE type = 'fb') AS fb_count, (select count(*) FROM posts WHERE type = 'email') AS email_count  FROM `posts` GROUP BY station_id;
  </code></pre>