-- case4 --
--========== rates ==========--
app0 1
app1 2
app2 2
app3 3
app4 3
app5 3
app6 5
app7 5
app8 5
app9 5
CREATE EXTERNAL TABLE rates (
app_name STRING
, star_rates STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
LOCATION '/tmp/db/rates';
create table app_ranks as
select app_name as app
, star_rates as stars
, NTILE(3) OVER (ORDER BY star_rates DESC) as nt
, row_number() OVER (ORDER BY star_rates DESC) as rn
, rank() OVER (ORDER BY star_rates DESC) as rk
, dense_rank() OVER (ORDER BY star_rates DESC) as drk
, CUME_DIST() OVER (ORDER BY star_rates) as cd
, PERCENT_RANK() OVER (ORDER BY star_rates) as pr
from rates
order by stars desc
;
select app, stars, cd, sum(cd) OVER (PARTITION BY stars ORDER BY rn ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT
hive ETL之业绩报表sql
最新推荐文章于 2024-08-17 16:46:05 发布
本文深入探讨了使用Hive进行ETL处理时,如何编写业绩报表的SQL查询。通过实例分析,揭示了Hive在大数据处理中的应用和优势。
摘要由CSDN通过智能技术生成