mysql> SELECT `team`,SUM(`for`) as `for`,SUM(`against`) as `against` ,SUM(`home`) as `home` FROM `element_fixture` WHERE `team` IN (SELECT `team_id` FROM -> `teams` WHERE `school_id`=2 and `sport_id`=1) AND `for` > -1 AND `against` > -1 GROUP BY `team` ORDER BY `team`; +------+------+---------+------+ | team | for | against | home | +------+------+---------+------+ | 5 | 6 | 6 | 2 | | 6 | 8 | 12 | 2 | +------+------+---------+------+ 2 rows in set (0.00 sec) mysql> mysql> SELECT `team`,COUNT(`fixture_id`) AS `won` FROM `element_fixture` WHERE `team` IN (SELECT `team_id` FROM `teams` WHERE `school_id`=2 and -> `sport_id`=1) AND `for` > `against` GROUP BY `team`; +------+-----+ | team | won | +------+-----+ | 5 | 2 | +------+-----+ 1 row in set (0.00 sec) mysql> mysql> SELECT `team`,COUNT(`fixture_id`) AS `lost` FROM `element_fixture` WHERE `team` IN (SELECT `team_id` FROM `teams` WHERE `school_id`=2 and -> `sport_id`=1) AND `for` < `against` GROUP BY `team`; +------+------+ | team | lost | +------+------+ | 5 | 1 | | 6 | 2 | +------+------+ 2 rows in set (0.00 sec) mysql> mysql> SELECT `team`,COUNT(`fixture_id`) AS `draw` FROM `element_fixture` WHERE `team` IN (SELECT `team_id` FROM `teams` WHERE `school_id`=2 and -> `sport_id`=1) AND `for` = `against` GROUP BY `team`; +------+------+ | team | draw | +------+------+ | 6 | 1 | +------+------+ 1 row in set (0.00 sec)