def average_rating(value): record = event_participation.query.add_columns( func.AVG(event_participation.rating).label('average')).filter( event_participation.event_id == value).first() return record
def highest_average_salary(): return session.query(Coach.name, func.AVG(Coach.salary)).group_by(Coach.name).order_by( func.AVG(Coach.salary).desc()).limit(5).all()
def average_coach_salary(): return session.query(Coach.name, func.AVG(Coach.salary)).group_by(Coach.name).all()
def average_all_coaches_salary(): x = session.query(func.AVG(Coach.salary)).filter(Coach.salary != 0).all() return round(x[0][0], 2)
def desc_temps_2(date1, date2): return session.query(func.MAX(Measurement.tobs), func.MIN(Measurement.tobs), func.AVG(Measurement.tobs)).\ filter(Measurement.date >= date1).filter(Measurement.date <= date2).all()
def average_coach_salary(): return session.query(Coach.name, func.AVG(Coach.salary), Coach.sal_school, Coach.years).group_by(Coach.name).all()