function withAGroupBy<T extends PgSelect>(query: T) {
return query
.leftJoin(...)
.groupBy(something1.id);
}
function withASecondGroupBy<T extends PgSelect>(query: T) {
return query
.leftJoin(...)
.groupBy(something2.id);
}
query = something.$dynamic;
withAGroupBy(query);
withASecondGroupBy(query);