Using a CTE because the query will probably return a few results I tried a IN clause but PG doesn't seem to be more efficient with it The CTE seems to be the only choice