How to use avg and sum in SQLAlchemy query

后端 未结 3 894
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 13:38

I\'m trying to return a totals/averages row from my dataset which contains the SUM of certain fields and the AVG of others.

I could do this in SQL via:

S         


        
3条回答
  •  醉话见心
    2021-02-01 13:58

    ttention = Attention_scores.query.with_entities(func.avg(Attention_scores.score)).filter(classroom_number == classroom_number).all()

    i tried like this . it gave the correct average

提交回复
热议问题