select category_id, (select category.name from category where category.id = category_id ) as category_name from ( select distinct category_id as category_id from model join category on ( category.id = model.category_id) ) as R
... self.current_session.query(Model.category_id).join(Category).distinct()
But how to know category_name ?
{}. Step 2. Clarify your question with -- perhaps -- the actual error message you're actually getting.