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

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -