add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table games (
game_id int,
game_date date,
arena varchar2(20),
home varchar2(30),
away varchar2(30),
home_points int,
away_points int
);

begin
insert into games(home, away, home_points, away_points)
values('AAA', 'BBB', 90, 100);
insert into games(home, away, home_points, away_points)
values('AAA', 'CCC', 99, 82);
insert into games(home, away, home_points, away_points)
values('AAA', 'DDD', 100, 78);
end;
/
1 rows affected
select t.team, round(avg(t.points), 2) avg_points
from games g
cross apply (
select home team, home_points points from dual
union all select away, away_points points from dual
) t
group by t.team
order by t.team
TEAM AVG_POINTS
AAA 96.33
BBB 100
CCC 82
DDD 78