Paste this into a new question or an answer at dba.stackexchange.com:
<!-- -->
> 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);
>
> <pre>
> ✓
>
> ✓
>
2 rows affected
>
5 rows affected
> </pre>
<!-- -->
> 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;
>
> <pre>
> team_id | sum
> ------: | --:
> 2 | 30
> 1 | 38
> </pre>
*db<>fiddle [here](https://dbfiddle.uk/?rdbms=postgres_10&fiddle=e2eed6b23014104d1d2969ea2d7353a6)*
back to fiddle