注意:请随时共享适用的资源。我发现这很困难。
我正在尝试编写以下python函数:
def player_with_max_points_per_game():
""" The player with highest average points per game"""
cur.execute('SELECT name, avg_points FROM players ORDER BY
avg_points')
# Now I want to select 'name' from the top row
PS:我意识到我的预期方法可能效率不高。我看到有一个MAX()函数。有什么建议吗?
答案 0 :(得分:0)
只需获取第一列的值即可。
cur.execute('SELECT name, avg_points FROM players ORDER BY avg_points DESC LIMIT 1')
row = cur.fetchone()
best_player_name = row[0]