击球率最高的前 10 名球员
Posted
技术标签:
【中文标题】击球率最高的前 10 名球员【英文标题】:Top 10 players with the highest batting average 【发布时间】:2021-06-03 19:36:33 【问题描述】:平均击球次数 = 总得分 / 超时次数。
在这里我们需要确保包括用完(在非前锋端)
输出如下:
Batsman_name Average
KL Rahul 44
错误:
SQL 语句中的错误:AnalysisException: cannot resolve '
batsman_runs
' given input columns: [_auto_generated_subquery_name.Batsman];第 1 行,第 21 行; '排序 ['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;
【问题讨论】:
【参考方案1】:因为从您的子查询(联合结果)中,您只返回“Batsman_”列。你必须返回所有你需要的列:
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;
【讨论】:
我没有得到正确的平均水平,我们需要确保包括用完(在非前锋端) 你在问一个新问题,我建议你发布一个带有示例数据和所需输出的新问题 数据存在于我附加的图像中,我也提到了所需的输出。【参考方案2】: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;
您在内部 sql 中忘记了字段“batsman_run & player_dismissed”
【讨论】:
我认为他们的登录平均有问题不是根据非罢工端用完的你能帮我吗 可能,但这是另一个问题,所以先关闭这个,测试你想要什么,然后问一个新问题,你还有其他问题。 我试过的代码我认为它会在消除错误后给我正确的输出,但它没有给出正确的输出。我已经附上了带有示例数据的图像以上是关于击球率最高的前 10 名球员的主要内容,如果未能解决你的问题,请参考以下文章
sql 在印度超级联赛中拥有最多男子比赛的前12名球员(2008年 - 2016年)