Java教程

Hive之例题

本文主要是介绍Hive之例题,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1.统计视频观看数Top10
select
    videoId,
    rank()over(order by views desc)
from gulivideo_orc
limit 10
+--------------+----------------+
|   videoid    | rank_window_0  |
+--------------+----------------+
| dMH0bHeiRNg  | 1              |
| 0XxI-hvPRRA  | 2              |
| 1dmVU08zVpA  | 3              |
| RB-wUgnyGv0  | 4              |
| QjA5faZF1A8  | 5              |
| -_CSo1gOd48  | 6              |
| 49IDp76kjPw  | 7              |
| tYnn51C3X_w  | 8              |
| pv5zWaTEVkI  | 9              |
| D2kJZOfq7zk  | 10             |
+--------------+----------------+
2.统计视频类别热度Top10(类别热度:类别下的总视频数)
select
    videoId,
    category,    
    category_name
from gulivideo_orc
lateral view explode(category) gulivideo_orc_tmp as category_name
+--------------+-----------------------+----------------+
|   videoid    |       category        | category_name  |
+--------------+--------
这篇关于Hive之例题的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!