result = dbsession.query(Shares.price, func.sum(Shares.quantity).label(
    'Total sold')).filter(Shares.company == 'Google').group_by(Shares.price
    ).all()
Using alias() for 'select as' in SQLAlchemy