clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601434 fiddles created (47997 in the last week).

create table team (id int, player_ids int[]); create table player(id int, score int); insert into team values (1, array[1, 2, 3]), (2, array[4, 5]); insert into player values (1, 10), (2, 15), (3, 13), (4, 14), (5, 16);
2 rows affected
5 rows affected
 hidden batch(es)


select t.id as team_id, sum(p.score) from team t, player p where p.id = any(t.player_ids) group by t.id;
team_id sum
2 30
1 38
 hidden batch(es)