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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -