sqlalchemy simple example of `sum`, `average`, `min`, `max`

See SQL Expression Language Tutorial for the usage. The code below shows the usage:

from sqlalchemy.sql import func
qry = session.query(func.max(Score.score).label("max_score"), 
                    func.sum(Score.score).label("total_score"),
                    )
qry = qry.group_by(Score.name)
for _res in qry.all():
    print _res

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)