其他分享
首页 > 其他分享> > 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  |
+--------------+--------

标签:category,name,+--------------+----------------+,Hive,gulivideo,类别,例题,orc
来源: https://blog.csdn.net/lslslslslss/article/details/122136261