col e heading "Wins"
col f heading "Losses"
select a, sum(nvl(e,0)) e, sum(nvl(f,0)) f
from
(select team_name a, count(*) e, null f
from teams, games
where team_id = winner_team_id
group by team_name
union
select team_name a, null e, count(*) f
from teams, games
where team_id = looser_team_id
group by team_name)
group by a;
Game
Team Won/ Game Start
Name Lost ID Date
---------- ---- ----- ---------
Giants L 2795 16-AUG-04
L 2803 17-AUG-04
Red Sox L 2773 13-AUG-04
W 2786 14-AUG-04
Yankees W 2773 13-AUG-04
L 2786 14-AUG-04
W 2795 16-AUG-04
W 2803 17-AUG-04
8 rows selected.