How to use a labelled column in sqlalchemy filter?
问题 I want to use the labelled column in sqlalchemy filter. for eg: db.session.query( PartMaster.name, PartMaster.description, PartTracker.actual_length, func.sum(PartTracker.quantity).label('quantity') ).join(PartTracker).group_by( PartTracker.part_master_id,PartTracker.actual_length ).all() I need the result with quantity > 0 . please advice 回答1: In SQL if you want to filter rows by result, you need to use HAVING instructions. So in your case: db.session.query( PartMaster.name, PartMaster