python - How to use a labelled column in sqlalchemy filter? -
i want use labelled column in sqlalchemy filter. 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 result quantity > 0
. please advice
in sql if want filter rows result, need use having instructions.
so in case:
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 ).having( func.sum(parttracker.quantity) > 0 )
example doc
Comments
Post a Comment