Skip to content
Discussion options

You must be logged in to vote

You can solve this using col():

    stmt = (
        select(
            Person.id,
            Person.name,
            func.count(col(TeamPersonLink.team_id)).label("team_count")
        )
        .select_from(Person)
        .outerjoin(TeamPersonLink, col(Person.id) == TeamPersonLink.person_id)
        .group_by(col(Person.id))
        .limit(page_size)
        .offset((page - 1) * page_size)
    )

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants