PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

Encontre todas as partidas de um determinado time no PostgreSQL

SELECT t.uuid, t.player_1_uuid, t.player_2_uuid, array_agg(m.uuid) as "match_uuids"
FROM teams t JOIN matches m ON t.uuid IN (m.team_a_uuid, m.team_b_uuid)
GROUP BY t.uuid;