Postgres Select Ids Into Array In Math