球队 比赛 反超球员及连续得分球员问题计算
问题:两支篮球队进行了激烈的篮球比赛,比分交替上升。比赛结束后,你有一张两队得分分数的明细表,记录了球队team,球员号码number,球员姓名name, 得分分数score 以及得分时间score_time(string,秒级)。现在球队要对比赛中表现突出的球员做出嘉奖,所以请你用sql统计出
1)比赛中帮助各自球队反超比分的球员姓名以及对应时间。
2)连续三次(及以上)为球队得分的球员名单以及对应时间段内获得的分数。
一 数据准备
1建表
hdfs dfs -mkdir '/tmp/yj_ext_csv_unc_basketball_game'
use tmp;
create external table tmp.yj_ext_csv_unc_basketball_game
(
team string,
number int,
score int,
score_time int
)
partitioned by (dt STRING)
row format delimited fields terminated by ',' lines terminated by '\n'
stored as textfile
LOCATION '/tmp/yj_ext_csv_unc_basketball_game/';
2.导入数据
数据样例:
a,2,1,0
a,1,2,1
a,1,3,2
b,1,4,3
a,1,2,4
b,2,5,5
b,6,3,6
a,1,5,7
a,3,2,8
b,2,4,9
b,5,3,10
a,1,2,11
a,1,3,12
b,5,4,13
a,4,3,14
a,4,2,15
a,4,3,16
b,6,7,17
hdfs dfs -put basketball.cav /tmp/yj_ext_csv_unc_basketball_game/20190527
altet table tmp.yj_ext_csv_unc_basketball_game parti