网站开发后台做些什么,怎么利用招聘网站做薪酬调查,时事新闻2022最新10月,html5响应式布局网站把一个容器的多个数据炸裂出单独展示: explode(容器) 需求:将NBA总冠军球队数据使用explode进行拆分#xff0c;并且根据夺冠年份进行倒序排序。
1.建表
--step1:建表
create table the_nba_championship(team_name string,champion_year arraystring
) row format…把一个容器的多个数据炸裂出单独展示: explode(容器) 需求:将NBA总冠军球队数据使用explode进行拆分并且根据夺冠年份进行倒序排序。
1.建表
--step1:建表
create table the_nba_championship(team_name string,champion_year arraystring
) row format delimited
fields terminated by ,
collection items terminated by |;2.加载数据
load data inpath /input/The_NBA_Championship.txt into table the_nba_championship; 3.验证数据
p3:验证数据
select * from the_nba_championship;
可以使用order by,但效率太低
--只查询冠军年份,降序排序
select explode(champion_year) as champ
from the_nba_championship order by champ ; --order by 太占用资源,效率低
使用炸裂函数,配合侧视图,制作新表
-- 将NBA总冠军球队数据使用explode进行拆分并且根据夺冠年份进行倒序排序。
--先将冠军年各个炸出来
select explode(champion_year) from the_nba_championship;--再将炸出来的结果用侧视图保存,和原表的球队名字拼起来with nba as (select team_name, c.champ_year_explodefrom the_nba_championshiplateral view explode(champion_year) c as champ_year_explode --冠军年份炸开后,存到虚拟表c,并起了个字段名,与原表进行拼接.--并将拼接完成的表起了个别名,作为排序查询的准备
)
select * from nba order by champ_year_explode desc ;
结果