击球率最高的前 10 名球员 [英] Top 10 players with the highest batting average

查看:33
本文介绍了击球率最高的前 10 名球员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

击球平均值 = 总得分/暂停次数.

Batting average = total number of runs scored / number of times out.

这里我们需要确保包括用完(在非前锋端)

Here we need to make sure to include run outs (on non-striker end)

输出如下:

Batsman_name     Average

KL Rahul            44

错误:

SQL 语句中的错误:AnalysisException:无法解析 'batsman_runs' 给定的输入列:[_auto_generated_subquery_name.Batsman];第 1 行 pos 21;'Sort ['Average DESC NULLS LAST], true

Error in SQL statement: AnalysisException: cannot resolve 'batsman_runs' given input columns: [_auto_generated_subquery_name.Batsman]; line 1 pos 21; 'Sort ['Average DESC NULLS LAST], true

select Batsman_, sum(batsman_runs)/count(player_dismissed) as Average 
from
(
 (select batsman as Batsman_ from IPL_BALL_BY_BALL) 
 union all 
 (select non_striker as Batsman_ from IPL_BALL_BY_BALL)
)
group by Batsman_ 
order by Average desc;

推荐答案

因为从你的子查询(联合的结果)你只返回Batsman_";柱子.你必须返回你需要的所有列:

because from your subquery ( result of union) you only returning "Batsman_" column. you have to retunr all the column you need :

select Batsman_, sum(batsman_runs)/count(player_dismissed) as Average 
from
(
 (select batsman as Batsman_,batsman_runs,player_dismissed from IPL_BALL_BY_BALL) 
 union all 
 (select non_striker as Batsman_,batsman_runs,player_dismissed from IPL_BALL_BY_BALL)
)
group by Batsman_ 
order by Average desc;

这篇关于击球率最高的前 10 名球员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆