popular_post_id = db.session.query(Post.id).filter(Post.place_id == Place.id
    ).correlate(Place).order_by(post_popularity.desc()).limit(1).as_scalar()
How can I query rows with unique values on a joined column?